Link within label - include extra functionality - asp.net

I have the following code in front that gives a bit of blurb and creates a link which the user can click and it sends them to a page specified.
<asp:Label ID="tbxFindOutMore" runat="server"
text="If you are already a member, please <a href ='Reporting/Login.aspx' target=_blank style=color:black>click here</a> to login to your bespoke reporting"
Font-Names="Trebuchet MS" Font-Size="12px" ForeColor="Black"></asp:Label>
Previously I used this as a link button and had the following click code behind to make the window maximise to full screen:
Page.ClientScript.RegisterStartupScript
(this.GetType(), "openwindow", "win = window.open('Reporting/Login.aspx');win.moveTo(0,0); win.resizeTo(window.screen.availWidth, window.screen.availHeight)", true);
How would I go about incorporating this functionality into the asp: label I am now using?

Why don't you do all this on client-side?
<script type="text/javascript" language="javascript">
function openReportingLogin() {
win = window.open('Reporting/Login.aspx');
win.moveTo(0,0);
win.resizeTo(window.screen.availWidth, window.screen.availHeight);
}
</script>
<span style="font-family: Trebuchet MS; font-size: 12px; color: black;">If you are already a memeber, please <a style="color: black;" href="javascript:openReportingLogin();">click here</a> to login to your bespoke reporting</span>

You shouldn't be putting mark-up in your Text property of a label. Instead, construct it as you would normally with HTML (I can't see a reason for this being an <asp:Label />:
<script>
function openwindow()
{
win = window.open('Reporting/Login.aspx');
win.moveTo(0,0);
win.resizeTo(window.screen.availWidth, window.screen.availHeight);
}
</script>
<span style="font-family: Trebuchet MS; font-size: 12px; color: black">
If you are already a member, please
click here
to login to your bespoke reporting
</span>

I agree with Codesleuth.
And if you like to manipulate things on the server-side, just add a runat="server" attribute to the appropriate html tag.
Chris

Related

Customize Form within iFrame via CSS (iFrame contents not editable)

I need help customizing a form with CSS. The form was auto generated and cannot be edited. The iframe simply opens this form within so I cannot add CSS to the contact form to effect it. See link for the form:
label {
color: red;
}
input {
color: green;
}
<h2>Contact Us </h2>
<b style="color: red;">NOTE: I would like to modify the label font, input, and "required" text.</b> <br /> <br /><br />
<iframe name="lc_contact_form" frameborder="0" width="100%" height="600" src="https://sindesignphotography.17hats.com/embed/lead/form/nffgsxgpxrcxvcdwwcvwdpwhfvwwcfsz"></iframe><script type="text/javascript" src="https://sindesignphotography.17hats.com/js/lib/iframeSizer.min.js"></script>
Get Cross-Domain iFrame content
You can't access cross domain content. If it is comming from your own domain, you can. Run my code and look at the console log. It throws a security error. This is to prevent 3rd party webapplications from reading your bank account information.
$('#getStuff').contents().find("input").css('color', 'green')
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
Can't Access iframe
<iframe id="getStuff" name="lc_contact_form" frameborder="0" width="100%" height="600" src="https://sindesignphotography.17hats.com/embed/lead/form/nffgsxgpxrcxvcdwwcvwdpwhfvwwcfsz"></iframe>

HTML5 tab hyperlink to pop-up

I have done a lot of research before posting it in here. So, here I got few imperfections.my link
Question 1: How do I make CV button to automatically pop-up the pdf resume or cv. So after I get this done, I won't need div saying lorem as a hyperlink.
Under the navigation class:
<li>CV</li>
When I replace #cv from href with a pdf link, the whole website goes wrong.
Thats it for now. Thanks in advance!
Javascript:
<script language="javascript" type="text/javascript">
<!--
function popitup(url) {
newwindow=window.open(url,'name','height=200,width=150');
if (window.focus) {newwindow.focus()}
return false;
}
// -->
</script>
HTML :
<li><a href="" onclick="return popitup('cv.pdf')" >CV</a></li>

<a href or <asp:hyperlink.....tag does not render at runtime

i am trying to display a simple div with hyperlink that represents x
like this:
So, when my run my app i see the div but i dont see the x which is <a href tag
and here is my code:
<div class="success">×status message here...</div>
and when i looked at the source of the page this is what it renders:
<div id="ctl00_ctl00_ContentMain_ContentMain_employee_status" class="success" style="display:block;">status message here...</div>
and then i tried with <asp:hyperlink....
<div class="success" id="divStatus" visible="false" runat="server"><asp:HyperLink id="success" runat="server" CssClass="close" Text="×"></asp:HyperLink></div>
and i still dont see href tag, what is going on here and why i am not able to render the <a href or <asp:hyperlnk tag any clue?
i am writing InnerHtml divSuccess.InnerHtml ="status message here...
if thats the case that erasing its static contents then what is the
alternate?
If divStatus contains controls that you want to keep, then you can append HTML to it by using a Literal control and adding it to the controls collection, like:
var lit = new Literal();
lit.Text = "my text or <strong>html</strong>";
this.divStatus.Controls.Add(lit);
Alternatively, you could use another control inside divStatus and alter its inner HTML:
<div id="divStatus" runat="server">
<a id="lnk1">This is the link that we don't want to be removed.</a>
<asp:Literal runat="server" id="litStatusHtml" />
</div>
here is how i able to solved my question
divStatus.InnerHtml = "<a href='#' class='close'>×</a>" + "status message here...";

asp.net - ajax drop drag proplem

i have a dragable "li" and i use ajax with asp.net. When I start the page drop-drag is working, but when I click the button it doesn't. How can I solve it? All help will be appreciated.
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="jquery-ui-1.7.1.custom.min.js"></script>
<script type="text/javascript" >
$(document).ready(function(){
$(function() {
$("#contentLeft ul").sortable({ opacity: 0.6, cursor: 'move', update: function() {
}
});
});
});
<div id="contentLeft" runat="server">
<ul id="mainOptions" runat="server">
<li id="recordsArray_2" runat="server">2. I am coming.</li>
<li id="recordsArray_1" runat="server">1. How areyou?</li>
<li id="recordsArray_4" runat="server">4. Which is yours?</li>
<li id="recordsArray_3" runat="server">3. This is a book.</li>
</ul>
</div>
<asp:Button ID="btnHelloWorld" runat="server" Text="Update label "
onclick="btnHelloWorld_Click" />
If you have your list inside update panel and script outside of it then $(document).ready will be fired only once when page is loaded. On this first load you set up drag and drop thing on your list.
Later you click a button and content of the update update is updated removing objects that have drag and drop plugins on them and passing fresh new ones from server. If you need to resetup drag and drop you can use page load event from asp.net ajax.

Using custom css within a Sharepoint webpart as a Embedded Resource is not working, why?

I've read in another question here how could I use custom CSS within my Sharepoint WebPart. So I followed this link:
http://www.synergyonline.com/blog/blog-moss/Lists/Posts/Post.aspx?ID=42
And I put my css as an embedded resource. Everything ok, I launch the page.
But my style doesn't appear.
I peek at the source code, and I find my resource:
<script src="/WebResource.axd?d=YuTREer2woiGbjiSaZdP0bLrdm6vpTygUffdwMFJr0zmn76B3vav0QRpmxzvYvKzZRnmgKpNbLHpnJf-W4rfrv-MrIZEoz6tWi5xHXTiN3lcxdP3s7ysDExW-eBQTlH8cUrMRw2&t=634369276247430484" type="text/javascript"></script>
Which leads me to my css:
.webPartContainer
{
background-color:Aqua;
}
.webPartContainer .Text
{
font-size:xx-large;
}
And here's where it references the styles:
<td class="ms-WPBorder" valign="top">
<div WebPartID="2109154d-6921-46ac-84d4-8ce24a926617" HasPers="false" id="WebPartctl00_m_g_2109154d_6921_46ac_84d4_8ce24a926617" width="100%" class="ms-WPBody" allowDelete="false" allowExport="false" style="" >
<div id="ctl00_m_g_2109154d_6921_46ac_84d4_8ce24a926617">
<div class="webPartContainer">
<span class="Text">Hello World with container!</span>
</div>
</div>
</div>
</td>
What's possibly happening ?
Thanks in advance !
EDIT: CssRegistration gives me permission errors, why ?
The browser don't expect the content of a <script type='text/javascript'> tag to be CSS.
So you should change your code to something like this:
string tempLink= "<link rel='stylesheet' text='text/css' href='{0}' />";
string location = Page.ClientScript.GetWebResourceUrl(this.GetType(), "myStyleSheet.css");
LiteralControl include = new LiteralControl(String.Format(tempLink, location));
Controls.Add(include);

Resources