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 b开发者_运维知识库ehind 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
<a href="javascript:openwindow();" target="_blank" style="color: black">click here</a>
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
精彩评论