|
-
May 19th, 2004, 03:51 AM
#1
Thread Starter
Fanatic Member
How can the user control know which web form it is on. *RESOLVED*
I have a user control on a webform. I need to put the user control on many web forms but the user control needs to know which web form it is on as different action will need to be taken depending on the web form.
How can the user control know which web form it is on.
Last edited by davidrobin; May 20th, 2004 at 06:18 AM.
-
May 19th, 2004, 04:52 PM
#2
Frenzied Member
EnsureChildControls()
Me/this.Page.ID
that should give you the name/id of the current page. you call EnsureChildControls to ensure Page will be there. Try not to think about the Me/this.Page.Page.Page.Page.Page.Page.Page.Page.Page.Page.ID issue it isn't documented if there is an issue.
Magiaus
If I helped give me some points.
-
May 20th, 2004, 03:32 AM
#3
Thread Starter
Fanatic Member
A little more information
I need to set the text of a textbox control that is on a user control to the name of the containing page.
The problem I am having is that the textbox is referenced as
<current page> -> form1 -> header1 -> textbox1.
Using ensurechildcontrols on my my page and placing
VB Code:
textbox1.text = me.page.id
on the usercontrol when ran the textbox text is blank.
I tried using a property on the Header1 control but when I type Header1.textbox1.text I get a 'header1' is not a member of 'test.Search'.
-
May 20th, 2004, 03:51 AM
#4
Thread Starter
Fanatic Member
I worked out how to do this using a property.
This is on my usercontrol
VB Code:
Public WriteOnly Property pp() As String
Set(ByVal Value As String)
TextBox1.Text = Value
End Set
End Property
This is in the general declaration section
And finally this in the page load event
VB Code:
j = Me.FindControl("Header1")
j.pp = myTitle.InnerText
I do have the me.ensurechildcontrols statement but it actually works without it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|