Topaz Filer - Email filing software
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...
 
New BootFX DBGet build available
Twitter and Snow… simple #uksnow
 
    
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...
 
Windows 7 compatible tool for mounting ISO images
Introduction to BootFX’s Object Relational Mapping Functionality article now live on CodeProject
 
    
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...
 
Xenu Link Sleuth
Chromium OS – really?
 
    
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...
 
Invocation Software – the new name for the makers of Topaz Filer
Agile Modeling
 
 
System.Web.UI.Page




Topaz Filer - Email filing software
Ad
BootFX
Reliable and powerful .NET application framework.
Looking to invest in a major software project? Technical and commercial advice available here.
Other Helpful Sites
MBR 247
Topaz Filer
SharePoint Email Filing
Software Advisory Services
 
Copyright © AMX Software Ltd 2008-2010. Portions copyright © Matthew Baxter-Reynolds 2001-2010. All rights reserved.
Contact Us - Terms of Use - Privacy Policy - 4.0.30129.1734