Topaz Filer: if you use e-mail for business, we can save you money and decrease your risk.
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.
I’m using VB.NET.

How should I do this? It seems one can’t just read the variables set by
the other.

Many thanks,
Matt
Reply to this message...
Vote that this is a GOOD answer...
 
Auto-following on Twitter
Ubuntu and XP on one “desktop”
 
    
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.
I’m using VB.NET.

How should I do this? It seems one can’t just read the variables set by
the other.

Many thanks,
Matt
Reply to this message...
Vote that this is a GOOD answer...
 
Outlook interop - stopping user properties appearing on Outlook message print
Seriously, why is “cut and paste” majorly newsworthy???
 
    
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]

Reply to this message...
Vote that this is a GOOD answer...
 
 
    
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]

Reply to this message...
Vote that this is a GOOD answer...
 
Email Archiving and Email Filing - what’s the difference?
Web-based task/todo list management
 
    
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]

Reply to this message...
Vote that this is a GOOD answer...
 
Open source windows
The Law Society’s guidelines on e-mail management
 
 
System.Web.UI.Page




Ad
BootFX
Reliable and powerful .NET application framework.
Recession Busting Bespoke Software
Get through the recession by investing in bespoke software to decrease costs and create commercial opportunities.
Other DN247 Network Sites
.NET 247
SQL Server Wins
Old Skool Developer
 
Copyright © AMX Software Ltd 2008-2009. Portions copyright © Matthew Baxter-Reynolds 2001-2009. All rights reserved.
Contact Us - Terms of Use - Privacy Policy - .NET 247 is a member of the DN247 Network - 4.0.30129.1734