0

We are in ASP.Net Webforms. I come from a LAMP Stack mindset...

ASPX Code (part of it)

<asp:Content runat="server" ContentPlaceHolderID="PH_MainContent">
    <h3 class="fleft">
        <asp:Literal runat="server" ID="li_title" />
...
<Example:userControl runat="server" someVariable="text" otherVariable=<%=li_title.Text%> thirdVariable=<%=Items["sort"].toString()%> />

So, li_title is a literal set in the code behind, I want to reuse it later, passing it to a userControl, where it shall be displayed in a javascript. Items is page.Items. I have also tried this.li_title (which is suggested to me in Visual Studio 2015).

After reading "quite a few" very similar questions, this seem the solution. However obviously I'm missing the point. What would that be..?

1 Answer 1

0

You can create a public property for each variable on your user control and set them in aspx. See this for more information

1
  • Hello Ali I came to the understanding that my usual way of variable visiblity inside the "Templating System" is not how ASP.NET works. Thus your suggestion - in my views unnececary overhead - is the only solution. And my natural lean approach is just not what this Framework is build for... For other .NET beginners. In my case its actually the li_title in the page that needs to be made a public property to be passed to the usercontrol. Alis example (I already knewn that ;) is same same but different
    – Alain
    Commented Dec 4, 2016 at 16:15

Not the answer you're looking for? Browse other questions tagged or ask your own question.