I tried to remove ctl00$ from server side button's name and id by overriding it's NamingContainer like:
namespace NoName
{
public class MatchingNameButton : Button
{
public override Control NamingContainer
{
get
{
return null;
}
}
}
}
and then registered that in aspx page:
<%@ Register TagPrefix="MatchingNameHtmlTextWriter" Namespace="NoName" Assembly="app_code" %>
and then button comes like this:
<MatchingNameHtmlTextWriter:MatchingNameButton runat="server" Text="btnTest" ID="btnTest" OnClick="btnTest_Click" />
and output is this:
<input type="submit" name="btnTest" value="btnTest" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions('btnTest', '', true, '', '', false, false))" id="btnTest">
this way is good for removing control path. but using this will prevent btnTest_Click event!
and it's so bad for me.
my question is: how should i keep button events in this way?
my .net version is 4.5
all helps will be appreciated.