c# - ASP.NET Passing variable from .aspx page to UserControl -


i have usercontrol want pass value .aspx page. i've setup property in usercontrol set value need page value null.

here control code in .aspx page,

<tcs:submitdatadiscrepancy runat="server" id="submitdatadiscrepancy" entitynameprop='<%# bind("association_name") %>'/> 

the .ascx code,

<div style="text-align:right;"> <asp:linkbutton id="reportlink" runat="server" text="report data discrepancy"></asp:linkbutton> 

<asp:panel id="reportpanel" runat="server" cssclass="modalpopup" style="width:auto;"> <div id="popheader" style="background-color: black; color: white; height: auto;">     report discrepancy         <div style="float: right;">             <asp:linkbutton runat="server" id="associationcanceltextbutton" causesvalidation="false" font-underline="false"                 cssclass="glyphicon glyphicon-remove white" tooltip="close" />         </div> </div> <div style="margin:10px;">     <div>         submit change request for: <asp:label id="entityname" runat="server" />     </div>     <div>         <textarea id="reporttextarea" runat="server" class="form-control" style="height: 100px; margin-bottom:10px; width: 100%;"></textarea>         <button id="reportsubmitbutton" runat="server" class="btn btn-primary" type="submit">submit</button>     </div> </div> 

and .ascx.cs page,

    public partial class submitdatadiscrepancy : system.web.ui.usercontrol {     public string entitynameprop { get; set; }      protected void page_load(object sender, eventargs e)     {         entityname.text = entitynameprop;     } } 

why not getting value i'm expecting .aspx page?

all variables disposed @ end of page's lifecycle, that's stateless nature of http. need way persist property. example use viewstate, session or hiddenfield (other ways).

in case makes sense use label.text:

public partial class submitdatadiscrepancy : system.web.ui.usercontrol {     public string entitynameprop {          { return entityname.text; }         set{ entityname.text = value; }     } } 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -