ascx

ASP.NET Is there a better way to find controls that are within other controls?

℡╲_俬逩灬. 提交于 2019-11-27 02:13:21
I currently have a dropdown inside an ascx control. I need to "find" it from within the code behind on another ascx that is on the same page. It's value is used as a param to an ObjectDataSource on ascx #2. I am currently using this ugly piece of code. It works but I realize if the conrtol order were to change or various other things, it wouldn't be where I am expecting. Does anyone have any advice how I should properly be doing this? if(Page is ClaimBase) { var p = Page as ClaimBase; var controls = p.Controls[0].Controls[3].Controls[2].Controls[7].Controls[0]; var ddl = controls.FindControl(

Pass data from a ASP.NET page to ASCX user controls loaded dynamically

巧了我就是萌 提交于 2019-11-27 00:51:08
问题 I'm developing an ASP.NET application with C# and Ajax. I have a page that holds user controls loaded dynamically. I need to pass some data (integer values and some strings) to the user control that has been loaded dynamically . Now I use Session to pass these values, but I think I can use another way; something like VIEWSTATE or hidden input. What do you recommend me? UPDATE: The fact that I load the controls dynamically is important because controls are loaded on every postback, and I can't

Is there a way to use “<%= someObject.ClientID %>” in an external javascript file?

此生再无相见时 提交于 2019-11-26 19:13:09
问题 Is there a way to use "<%= someObject.ClientID %>" in an external javascript file? If I use the code <%= someObject.ClientID %> in a script tag inside my as(c/p)x page, it works fine. On the rendered page, the ClientID is resolved. Howvever, if I put in an external JS file and just add: It doesn't. Is there a way to do this or am I stuck with leaving that code in the as(c/p)x file? Side question -- what is the act of doing <%=... %> in your markup file called? 回答1: This is totally possible.