Setting user control property dynamically?

Discussion in 'ASP .Net Building Controls' started by Dave, May 27, 2004.

  1. Dave

    Dave Guest

    Hi I created a user control that has a property that accepts a url ("NavUrl")..

    I tried to set the value as follows directly in the aspx page where strLink would be a link.

    <uc1:mycontrol id="mycontrol2" runat="server" HtmlContent="html stuff goes here." ImgUrl="myimage.gif" NavUrl="<%Response.Write(strLink);%>"></uc1:mycontrol

    Literal content ('">') is not allowed within a 'ASP.mycontrol_ascx'

    The only way I was able to set this property dynamically was on referencing the control in my codebehing and set the property in the page_load()...is this the only way?
    Dave, May 27, 2004
    #1
    1. Advertising

  2. Dave

    Natty Gur Guest

    HI,


    That should work :

    Page code :

    protected string s()
    {
    return "\"natty\"";
    }


    ASPX :
    <form id="Form1" method="post" runat="server">
    <uc1:a id="A1" URL=<%Response.Write(s());%> runat="server"></uc1:a>
    </form>


    generate HTML :
    <uc1:a id="A1" URL="natty" runat="server"></uc1:a>

    Natty Gur[MVP]

    blog : http://weblogs.asp.net/ngur
    Mobile: +972-(0)58-888377


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Natty Gur, May 28, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Amir Eshterayeh

    Error Setting user control property at web form

    Amir Eshterayeh, Nov 27, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    541
    Amir Eshterayeh
    Nov 27, 2003
  2. Karl Lang
    Replies:
    2
    Views:
    314
    Karl Lang
    Jun 17, 2004
  3. Guest
    Replies:
    2
    Views:
    465
    Guest
    Oct 1, 2006
  4. Nathan Sokalski
    Replies:
    25
    Views:
    1,426
    Nathan Sokalski
    Mar 4, 2010
  5. Travis Pruitt

    Dynamically Adding User Control with Child User Control

    Travis Pruitt, Jan 13, 2005, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    180
    Travis Pruitt
    Jan 13, 2005
Loading...

Share This Page