postback __EVENTTARGET ID in Page.Request.Form has $ not _ in ASP.NET
I am using the ToolkitScriptManager from the Ajax tool kit and I am having a problem finding my button's ID.
My ID's on my controls come back with $ symbols instead of _ symbols, like the following:
Grid$ctl06$insertButton
This obviously causes problems when attempting to find the control fro开发者_高级运维m the Page.Request.Form keys. I cannot seem to find the determining factor that would cause this.
Now, I know this is the name and in my source I see that the ID is with the _, so why is the Page.Request.Form showing up with the $ symbol instead? Anybody encounter this before?
UPDATE: Is it possible that since this button is nested within the Grid that is in the UpdatePanel, it is not found in the PreInit event? I see many other controls have already been initialized by this point, but this one has not.
In ASP.NET, the control IDs have '_' and the control names have '$'. The form collection is based on name, not on ID which is why you are seeing this behavior. As a side note, it looks like you are using controls within a databound grid, have you tried to use the grid's event handlers to handle these actions? Then you wouldn't need to know which row or grid that it came from. An example of a grid view event handler
精彩评论