vendredi 31 juillet 2015

Passing value to a user control from asp.net Page

I have following user control my .ascx Page. (Test.ascx)

<uc:Addresses runat="server" itemId='<%# StringId %>'></uc:SNETAddresses>

In the code behind of Test.ascx I have

protected string StringId = "{2A06199B-ED96-42F0-AB9A-602139E58BFB}";

In the code behind of user control Addresses.cs I have:

 public string itemId { get; set; }

So basically I want to pass a string to the variable itemId. But Somehow its not getting the value of variable "StringId". This simple thing is taking my so much time. I checked this post asp.net passing string variable to a user control but I am so sorry I could not get the answer. The reply is:

You may need to call DataBind on your Page in CreateChildControls or some other method 

I am new to Asp.Net and I didn't get what the user mean here.

Aucun commentaire:

Enregistrer un commentaire