Hi,<BR><BR>I am trying to set one of the properties of a web server control dynamically, and don't know how it should best be done.<BR><BR>Specifically, I want to dynamically set the NavigateURL property of this Hyperlink control:<BR><BR><asp:HyperLink runat="server" id="hlDisplayItemText" NavigateUrl="DisplayItemText.aspx" Text="Display ItemText" Target="_self" /> <BR><BR>Firstly, this link should not always take the user to page DisplayItemText.aspx - I want to be able to link to other pages, depending on what else is going on on the page.<BR><BR>Secondly, I also want to pass variables from the current page to the linked page (whether this linked page is DisplayItemText.aspx or some other one), and was trying to do this via the query string. However, my first naive attempt (below) just threw errors:<BR><BR>Dim strPassVariable as String = "?Variable=xyz"<BR><BR><asp:HyperLink runat="server" id="hlDisplayItemText" NavigateUrl=<% Response.Write("DisplayItemText.aspx" & strPassVariable) %> Text="Display ItemText" Target="_self" /> <BR><BR>I suspect I am still thinking ASP 3.0 - there must be some super, slick ASP.NET way of doing this! Can anyone tell me how?<BR><BR>Thanks,<BR><BR>JON<BR><BR>Jon -<BR><BR>Have you tried setting the NavigateURL property of the asp:Hyperlink class in your script instead of trying to dynamically write it into the page?<BR><BR>Instead of your example, within your script code that processes the user input from the page why note set the property like:<BR><BR>Dim MyURLVariable As String<BR><BR>MyURLVariable = InputToPreformatString & "?Variable=" & inputToformatVariable<BR><BR>hlDisplayItemText.NavigateUrl = MyURLVariable<BR><BR>------<BR>And the asp:Hyperlink on the page:<BR><BR><asp:HyperLink id="h1DisplayItemText" runat="server"<BR> Text="Display Item Text"<BR> Target="_self"<BR>/><BR><BR>Of course, you'll probably want the Page_Load to fire a default link value for MyURLVariable too.<BR>part of the attraction of .NET is separating our markup from our code, so you could do everything this way...<BR><BR><script runat=server language=vb><BR>Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<BR><BR>Dim strPassVariable as String = "?Variable=xyz"<BR><BR>with hlDisplayItemText<BR>.NavigateUrl = "DisplayItemText.aspx" & strPassVariable<BR>.Text = "Display ItemText"<BR>.Target = "_self"<BR>end with<BR><BR>end sub<BR></script><BR><BR><asp:HyperLink runat="server" id="hlDisplayItemText" /> <BR><BR>this way you don't use any <%%> delimeters and it's all handled in the same place. If you're REALLY into separation you can get into code-behind, by placing all logic in an entirely different file.Hi,<BR><BR>Thanks to webslinger and kidk for your advice. I have got it working now, with this code:<BR><BR>JON<BR><BR>********************************************<BR><BR>objHlDisplayItemText = new HyperLink<BR>objHlDisplayItemText.ID = "hlDisplayItemText"<BR>objHlDisplayItemText.NavigateUrl = "DisplayItemText.aspx?iCurrentRecord=" & ViewState("iCurrentRecord")<BR>objHlDisplayItemText.Text="Display ItemText"<BR>objHlDisplayItemText.Target="_self"<BR>Page.FindControl("PlaceHolder1").Controls.Add(objHlDisplayItemText) <BR><BR>********************************************