Having some strange behavior here. I have some XSLT which generates some html with a few ASP.NET Link Button Controls
String mstring = sw.ToString();
var myctrl = Page.ParseControl(mstring);
foreach (Control Control in myctrl.Controls)
{
if (Control is LinkButton)
{
LinkButton lb = (LinkButton)Control;
lb.OnClientClick = "LoadPromo";
}
Panel1.Controls.Add(myctrl);
}
protected void LoadPromo(object sender, EventArgs e)
{
Console.Write(e.ToString());
}
now it takes this control:
<asp:LinkButton ID="LinkButton2" runat="server" OnClick="LoadPromo" Text="Get your Free 2" />
and changes it to this when I add an event:
<a onclick="LoadPromo;" id="dnn_ctr954_ViewPromotions_LinkButton2" href=" WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("dnn$ctr954$ViewPromotions$LinkButton2", "", true, "", "", false, true))">Get your Free 2 a>
Now as you can see, it changes the onclick to like javascript instead of the asp.net control.It changes "LoadPromo" to "LoadPromo;". What can i do to get around this?
Thanks In Advance
Things I have tried:
lb.Click += LoadPromo;
I get this output:
<a id="dnn_ctr954_ViewPromotions_LinkButton2" href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("dnn$ctr954$ViewPromotions$LinkButton2", "", true, "", "", false, true))">Get your Free 2</a>