This is a migrated thread and some comments may be shown as answers.

Find MasterPage Control

1 Answer 85 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Mugil
Top achievements
Rank 1
Mugil asked on 05 Dec 2013, 04:18 PM
Hi,


     I have anchor tag in my masterpage.I want to find that control.

     And want to trigger confirm alert  in onclick of that control.


Thanking you,

P.Mugil


 

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 06 Dec 2013, 03:21 AM
Hi Mugil,

Please have a look into the following C# code to find the Master Page anchor tag in the Content Page and trigger a confirm alert on the Click event of the anchor tag.

Content Page C# :
protected void Page_Load(object sender, EventArgs e)
{
    //acceesing the anchor tage in the content page
    HtmlAnchor anchortag=(HtmlAnchor) this.Master.FindControl("anchor1");
    //assigning click event for the anchor tag
    anchortag.ServerClick += new EventHandler(anchortag_ServerClick);
}
void anchortag_ServerClick(object sender, EventArgs e)
{
    //confirm alert
    Page.ClientScript.RegisterStartupScript(this.GetType(), "confirmDelete", "confirm('Are you sure you want to delete this?');", true);
}

Thanks,
Princy.
Tags
General Discussions
Asked by
Mugil
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or