Jaggi Jaggi - 16 days ago 4
ASP.NET (C#) Question

How to bind data from ascx.cs page to ascx page?

I got some bunch of data from a service and deserialized and kept in variable 'StoreDetails' like below.

var StoreDetails= JsonConvert.DeserializeObject<Info.Wrapper>(json);

Sample data what StoreDetails contain is:

{"Status":{"StatusCode":200,"StatusDisplay":"OK","StatusValue":true,"Version":2},"Store":[{"Carry Out":false,"Coupons":true,"CustomURL":"https:\/\/ordering.com\/5702\/locations\/7725","DeliveryAvailable":false,"Distance":1.05,"Drive Thru":false,"FranchiseStoreId":0000002,"HasPromotion":false,"}]

I want to pull this data from ascx.cs page to ascx page. I know how to pull data in cshtml page using model like below, but I'm now sure in aspx to pull data.



Can someone help me to pull data and display in a list.

Win Win

If I understand your question correctly, you can use Literal control to pass plain data (without additional markup) from Code Behind.


<h4><asp:Literal runat="server" ID="Address1Literal" /></h4>

Code Behind

protected void Page_Load(object source, EventArgs e)
    Address1Literal.Text = "Some text";

You can even pass JSON data directly to script tag.