views:

63

answers:

3

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?

A: 

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
    <a href="javascript:openwindow();" target="_blank" style="color: black">click here</a>
    to login to your bespoke reporting
</span>
Codesleuth
Hello Codesleuth - that's me learning the ropes I am afraid and not really knowing what I am doing! Thanks for the pointers though, I shall keep them in mind.
Ricardo Deano
+1  A: 

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>
Brandon Montgomery
I was editing my answer to include the script and got a phone call, damn you for getting there first :pBut nice answer :)
Codesleuth
Exactly what I wanted Brandon, thank you very much - being a noob, I wasn't sure how to go about incorporating the differetn elements. Thank you for the help.
Ricardo Deano
A: 

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

Chris