|
| Passing variables from ASPX to ASCX |
|
|
|
|
| Messages |
|
Related Types |
This message was discovered on ASPFriends.com 'aspngreuse' list.
| Matthew Killick |
I have a web form which contains a user control. I need to be able to set a variable value in the web form and read it from the user control. Im using VB.NET.
How should I do this? It seems one cant just read the variables set by the other.
Many thanks, Matt
|
|
|
| |
|
| |
| |
| Daniel Naumann |
I have a web form which contains a user control. I need to be able to set a variable value in the web form and read it from the user control. Im using VB.NET.
How should I do this? It seems one cant just read the variables set by the other.
Many thanks, Matt
|
|
|
| |
|
| |
|
| |
| M Killick |
Thanks for the reply. I haven't used the Set command before.
Do you mean that if I *Set* a value in the parent page I can read the value in the user control normally?
Is this code correct?
Set(ByVal Value As String)
concertids = Value
End Set
Thanks, Matt
"Daniel Naumann" <Click here to reveal e-mail address> wrote in message news:673183@aspngreuse... [Original message clipped]
|
|
|
| |
|
|
| |
|
| |
| Trevor Pinkney |
Hi,
Here is some quick syntax.
its something like this (from within the usercontrol)
C# System.Web.UI.Page CallingPage; CallingPage = (System.Web.UI.Page)this.Page
but at work we have every Page derive from a basepage, so we go
OurProjectName.BasePage CallingPage; CallingPage = (OurProjectName.BasePage)this.Page
CallingPage.WhateverMethod(); //Whatever method found on the base page.
You may want to use an interface in your case... I'm not sure if VB supports those. but... C# it would be something like
public interface myInterface { public void FillTextBox(string text); }
-------------
Then your page implement the interface
public class yourpagewithusercontrol : myInterface { public void FillTextBox(string text) { someTextBox.Text=text; } }
then in your user control you go
myInterface m; m = (myInterface)this.Page; m.FillTextBox(somevalue);
I really should be providing some code examples but I'm just heading out the door for work!
Let me know if you need a better explanation.
-Trevor
At 11:50 AM 6/21/2002 +0100, you wrote: [Original message clipped]
|
|
|
| |
|
| |
|
| |
| M Killick |
Thanks for the help. I've got that working now.
Cheers, Matt "Trevor Pinkney" <Click here to reveal e-mail address> wrote in message news:673488@aspngreuse... Hi,
Here is some quick syntax.
its something like this (from within the usercontrol)
C# System.Web.UI.Page CallingPage; CallingPage = (System.Web.UI.Page)this.Page
but at work we have every Page derive from a basepage, so we go
OurProjectName.BasePage CallingPage; CallingPage = (OurProjectName.BasePage)this.Page
CallingPage.WhateverMethod(); //Whatever method found on the base page.
You may want to use an interface in your case... I'm not sure if VB supports those. but... C# it would be something like
public interface myInterface { public void FillTextBox(string text); }
-------------
Then your page implement the interface
public class yourpagewithusercontrol : myInterface { public void FillTextBox(string text) { someTextBox.Text=text; } }
then in your user control you go
myInterface m; m = (myInterface)this.Page; m.FillTextBox(somevalue);
I really should be providing some code examples but I'm just heading out the door for work!
Let me know if you need a better explanation.
-Trevor
At 11:50 AM 6/21/2002 +0100, you wrote:
Thanks for the reply. I haven't used the Set command before.
Do you mean that if I *Set* a value in the parent page I can read the value in the user control normally?
Is this code correct?
Set(ByVal Value As String)
concertids = Value
End Set
Thanks, Matt
"Daniel Naumann" <Click here to reveal e-mail address> wrote in message news:673183@aspngreuse... [Original message clipped]
| http://www.aspfriends.com/aspfriends/aspngreuse.asp = JOIN/QUIT </BODY> [Original message clipped]
|
|
|
| |
|
| |
|
|
|
|
|
|
|
|
BootFX
Reliable and powerful .NET application framework. |
|
|
|
|
|
|