Adding onserverclick event to a HtmlAnchor dynamically
I've got a page and would like to append the onserverclick event to my
existing HtmlAnchor.
In the design view I am first adding the control
<a runat="server" id="lnkFre" title="FR"
onclick="document.getElementById('ctl00_hidLang').value='en-US';"><span>Français</span>
</a>
I tried like this.
HtmlAnchor lnkFre = FindControl("lnkFre") as HtmlAnchor;
lnkFre.ServerClick += new EventHandler(lnkLang_Click);
Here the lnkLang_Click is an event in a class which is accessible from
this page.
But at runtime it is not being added.
I wish to have something like this.
<a runat="server" id="lnkFre" title="FR" onserverclick="lnkLang_Click"
onclick="document.getElementById('ctl00_hidLang').value='fr-BE';"><span>Français</span>
</a>
Is this possible in this way? Or kindly suggest me another method.
Thanks a lot
No comments:
Post a Comment