By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,836 Members | 2,018 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,836 IT Pros & Developers. It's quick & easy.

How can I change the NavigateUrl inside the user control ?

P: n/a
I created a user control containing containing a few hyperlinks.
How can I change the NavigateUrl inside the user control ?

So far I did the following:

1) In the custom control

Expand|Select|Wrap|Line Numbers
  1. Public Property SetURL()
  2. Get
  3. SetURL= sModificarURL
  4. End Get
  5. Set(ByVal Value)
  6. sModificarURL = Value
  7.  
  8. End Set
  9. End Property
  10.  
  11. Private Sub Page_PreRender(ByVal sender As Object, ByVal e As
  12. System.EventArgs) Handles MyBase.PreRender
  13. Me.hlnkModificar.NavigateUrl = sModificarURL
  14. End Sub
  15.  
2) In the page containing the control:
Expand|Select|Wrap|Line Numbers
  1. Dim cc As New myCustomControl
  2. cc.SetURL= "Cv_1.aspx?x=" & Request("x")
  3.  
My problem is that at PreRender the value I passed down to the property
doesn't exist any more.

Any other way of achieving this ?
Jean-Luc
www.corobori.com

Mar 8 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
First of all, it's better to directly assign to and get data from NavigateUrl
rather than via PreRender event:

Public Property SetURL() As String
Get
Return Me.hlnkModificar.NavigateUrl
End Get
Set(ByVal Value)
Me.hlnkModificar.NavigateUrl = Value
End Set
End Property

Seconly, you should get reference of usercontrol rather than create a new
usercontrol instance.

Dim cc As myCustomControl = CType(Me.FindControl(myCustomControl_ID),
myCustomControl)
cc.SetURL= "Cv_1.aspx?x=" & Request("x")
HTH

Elton Wang

"je**********@gmail.com" wrote:
I created a user control containing containing a few hyperlinks.
How can I change the NavigateUrl inside the user control ?

So far I did the following:

1) In the custom control

Expand|Select|Wrap|Line Numbers
  1.      Public Property SetURL()
  2.          Get
  3.              RE\\>         End Get
  4.          Set(ByVal Value)
  5.              sModificarURL = Value
  6.          End Set
  7.      End Property
  8.      Private Sub Page_PreRender(ByVal sender As Object, ByVal e As
  9.  System.EventArgs) Handles MyBase.PreRender
  10.          Me.hlnkModificar.NavigateUrl = sModificarURL
  11.      End Sub
  12.  

2) In the page containing the control:
Expand|Select|Wrap|Line Numbers
  1.          Dim cc As New myCustomControl
  2.          cc.SetURL= "Cv_1.aspx?x=" & Request("x")
  3.  

My problem is that at PreRender the value I passed down to the property
doesn't exist any more.

Any other way of achieving this ?
Jean-Luc
www.corobori.com

Mar 8 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.