I'm stuck with this dynamic control ID generation,if I put my controls(say Button) in ContentPage (which is inherited by MasterPage) inside <asp:Content></asp:Content>
when the page is rendered in the browser then the control Id are changed ,I read ScottGu article on 'clientIDMode' and I thought my problem is over so I set 'clientIDMode' inside 'Web.Config'
<pages clientIDMode="Static"></pages>
But the problem persists I can't refer my controls from code behind like this,
//ctl00$Cntnt$Button1 name works but its dynamically created
if (ScriptManager1.AsyncPostBackSourceElementID == "Button1")
{
Label1.Text = "Async PostBack occured @ " + DateTime.Now.ToLongTimeString();
}
ASP.net Markup:
<asp:Button ID="Button1" runat="server" Text="Refresh me" onclick="Button1_Click" />
Browser Side Markup:
<input type="submit" name="ctl00$Cntnt$Button1" value="Refresh me" id="Button1" />
Q) Can't I use just the Id of controls which I have specified in the Markup (as if I don't have any MasterPage)?
P.S: On AsyncPostback I want to perform certain operations based on specific Button which made AsyncPostback ,to do that I have to check value from AsyncPostBackSourceElementID
which unfortunately returns modified ControlID