Setting user control property dynamically?

D

Dave

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?
 
N

Natty Gur

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top