How to show hyperlink,linkbutton text on title bar of Internet Exlporer..

Posted by Susantaown under ASP.NET on 3/5/2009 | Views : 2095 | Status : [Member] | Replies : 6
Hello Everybody

I have several hyperlinks, Lnkbuttons, HyperlinkImageButton in my website..
My requirement like whenever user will click on those avove things the hyperlink text should be displayed on the title of Internet Explorer..

example like.

Linkbutton1.Text=hi how r u
Linkbutton2.Text=susant
Linkbutton3.Text=I m new to this site

Like this several links are availble in my web-page.. so suppose user is clicking on Linkbutton1i wana show "u click susant" like that...

Anybody help in this query




Responses

Posted by: Majith on: 3/5/2009 [Member] Starter

Up
0
Down
Greetings,

On the LinkButton / Button / HyperLink Click Event add the following code.

protected void LinkButton1_Click(object sender, EventArgs e)
{
Page.Title = LinkButton1.Text;
}

Button Click

btnADD // Id of the Button
Page.Title = btnADD.Text;

Thanks

Susantaown, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Susantaown on: 3/5/2009 [Member] Starter

Up
0
Down
Hi Majith
ThanX for ur Rply..

suppose i have 50 linkbuttons, and 50hyperlink in one webpage so accoring to u i have to write each click event i mean 100 lines ??

susant

Susantaown, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Neeks on: 3/5/2009 [Member] Bronze

Up
0
Down
Hi Susantaown,
You can write the code as shown below

protected void btn_Click(object sender, EventArgs e)

{
Page.Title = ((LinkButton)sender).Text;
}


You can call this event from your every LinkButton as shown below.
<asp:LinkButton ID="LinkButton1" runat="server" OnClick="btn_Click">hi how r u </asp:LinkButton></div>
<asp:LinkButton ID="LinkButton2" runat="server" OnClick="btn_Click">susant </asp:LinkButton></div>
<asp:LinkButton ID="LinkButton3" runat="server" OnClick="btn_Click">I m new to this site</asp:LinkButton></div>




Susantaown, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Susantaown on: 3/5/2009 [Member] Starter

Up
0
Down
Hi Nikhil

ThanX for ur valuable time for solving my problem..

Ur code is working fine with LinkButton but hyperlink has no OnClick event.. so for hyperlink what we can do??

susant
Mumbai

Susantaown, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Majith on: 3/5/2009 [Member] Starter

Up
0
Down
Susant,

For HyperLink there is an event called onserverclick you can write below code:

<a href="Funda.aspx" onserverclick="Button1_Click" runat="server">Susant</a>

Susantaown, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Neeks on: 3/5/2009 [Member] Bronze

Up
0
Down
Your CS file code will be:
protected void LinkButton1_Click(object sender, EventArgs e)

{
Page.Title = ((HtmlAnchor)sender).Name;
}


Your ASPX code will be
<a href="Default.aspx" name="Hiiii" runat="server" onserverclick="LinkButton1_Click">Hiiii</a>


You can change the "name" of the HyperLink as you required

Thanks,

Susantaown, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response