Mare22
asked on
ASP.NET - getting control's ID from code behind
I have a bunch of controls (specifically, asp:ImageButton) being part of Gridview on .aspx page,
with runat="server" specified, of course. I would expect them to be automatically included
in aspx.designer.cs file, and thus be accessible by id in .cs file, but they are not there.
How to make them be included on the server side and be accessible by id in .cs file?
Thank you.
with runat="server" specified, of course. I would expect them to be automatically included
in aspx.designer.cs file, and thus be accessible by id in .cs file, but they are not there.
How to make them be included on the server side and be accessible by id in .cs file?
Thank you.
are you copying ASPX markup from ASP.NET Website to ASP.NET Web-application?
Or you have added those controls to web-application on your own? If you have added them then it should be accessible in .cs file
check your aspx.designer.cs file for all controls' entries your are trying to accesss.
Or you have added those controls to web-application on your own? If you have added them then it should be accessible in .cs file
check your aspx.designer.cs file for all controls' entries your are trying to accesss.
ASKER
minhvc: thanks for your reply. Your links contain a lot of useful information, and I tried some suggestions from there, like deleting and regenerating my aspx.designer.cs file and using FindControl, but I still can't get my controls.
ASKER
minhvc: what I am trying to say is that I did create the controls on my own and I checked my aspx.designer.cs file. They are not there. They are inside a gridview on aspx page.
in aspx.designer.cs file you should be able to locate auto generated code similar to like this:
If its not there then there is something wrong.
public partial class _Default {
/// <summary>
/// btn1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Button btn1;
/// <summary>
/// btn control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Button btn;
}
If its not there then there is something wrong.
ASKER
gery128:
Once again, this is exactly what's missing.
Once again, this is exactly what's missing.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Would mind sharing some of your code?
http://forums.asp.net/t/1427858.aspx/1