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

Passing data to another aspx in different frame

P: n/a
I have a web page with 2 frames. The left frame is running menu.aspx and the
right frame is running images.aspx. When a selection is made in menu.aspx I
call a method in images.aspx and pass a variable. The intention is that
images.aspx will take the variable and load images into its frame (the right
one) based on the variable passed. What actually happens is the method runs
in the left frame and ruturns the error "Object reference not set to an
instance of a oblect" in the left frame. Nothing happens in the right frame.
The exception is pointing to the line of code located in images.aspx.cs.
How do I make the code in images.aspx.cs affect the frame it is in instead of
the frame it is called from?

Code in menu.aspx.cs:
private void Button1_Click(object sender, System.EventArgs e)
{
string tsource = Startup.MainSource[ListBox1.SelectedIndex].ToString();
string tlongdate = ListBox1.SelectedValue.ToString();
TextBox1.Text = tsource; //local to menu.aspx
Images gi = new Images();
gi.GetImages(tlongdate, tsource);
}

Code in images.aspx.cs:
public void GetImages(string LongDate, string Source)
{
Images mn = new Images();
//this text box is on images.aspx
mn.TextBox1.Text = LongDate; //here is the error
}

Thanks,
Evan R. Hicks
Nov 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
You must understand that menu.aspx and images.aspx do not exist on the
server at the same instance in time, therefore they cannot communicate
directly with each other.
Instead you need to use other techniques, such as client side code and/or
Session state to pass data between the pages.
This is one reason I try to avoid frames with ASP.NET; it's usually too
complex to be worth it.
Instead it's generally a better idea to use User Controls to divide up
logical sections of your pages.

Here's more info:
http://msdn.microsoft.com/library/de...ercontrols.asp
http://msdn.microsoft.com/library/de...ercontrols.asp
http://msdn.microsoft.com/library/de...ebControls.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"Evan" <Ev**@discussions.microsoft.com> wrote in message
news:0F**********************************@microsof t.com...
I have a web page with 2 frames. The left frame is running menu.aspx and
the
right frame is running images.aspx. When a selection is made in menu.aspx
I
call a method in images.aspx and pass a variable. The intention is that
images.aspx will take the variable and load images into its frame (the
right
one) based on the variable passed. What actually happens is the method
runs
in the left frame and ruturns the error "Object reference not set to an
instance of a oblect" in the left frame. Nothing happens in the right
frame.
The exception is pointing to the line of code located in images.aspx.cs.
How do I make the code in images.aspx.cs affect the frame it is in instead
of
the frame it is called from?

Code in menu.aspx.cs:
private void Button1_Click(object sender, System.EventArgs e)
{
string tsource = Startup.MainSource[ListBox1.SelectedIndex].ToString();
string tlongdate = ListBox1.SelectedValue.ToString();
TextBox1.Text = tsource; //local to menu.aspx
Images gi = new Images();
gi.GetImages(tlongdate, tsource);
}

Code in images.aspx.cs:
public void GetImages(string LongDate, string Source)
{
Images mn = new Images();
//this text box is on images.aspx
mn.TextBox1.Text = LongDate; //here is the error
}

Thanks,
Evan R. Hicks

Nov 19 '05 #2

P: n/a
That answers my question about my current behavior. The problem is that I am
converting an existing site to .NET and it uses two asp pages in separate
frames. Is there a way that a button click on menu.aspx can load images.aspx
in another frame? I can pass the data on the url line for the communication
between the pages. I was thinking maybe Response.Redirect but there is no
option for a target frame.

Thanks,
Evan

"Steve C. Orr [MVP, MCSD]" wrote:
You must understand that menu.aspx and images.aspx do not exist on the
server at the same instance in time, therefore they cannot communicate
directly with each other.
Instead you need to use other techniques, such as client side code and/or
Session state to pass data between the pages.
This is one reason I try to avoid frames with ASP.NET; it's usually too
complex to be worth it.
Instead it's generally a better idea to use User Controls to divide up
logical sections of your pages.

Here's more info:
http://msdn.microsoft.com/library/de...ercontrols.asp
http://msdn.microsoft.com/library/de...ercontrols.asp
http://msdn.microsoft.com/library/de...ebControls.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"Evan" <Ev**@discussions.microsoft.com> wrote in message
news:0F**********************************@microsof t.com...
I have a web page with 2 frames. The left frame is running menu.aspx and
the
right frame is running images.aspx. When a selection is made in menu.aspx
I
call a method in images.aspx and pass a variable. The intention is that
images.aspx will take the variable and load images into its frame (the
right
one) based on the variable passed. What actually happens is the method
runs
in the left frame and ruturns the error "Object reference not set to an
instance of a oblect" in the left frame. Nothing happens in the right
frame.
The exception is pointing to the line of code located in images.aspx.cs.
How do I make the code in images.aspx.cs affect the frame it is in instead
of
the frame it is called from?

Code in menu.aspx.cs:
private void Button1_Click(object sender, System.EventArgs e)
{
string tsource = Startup.MainSource[ListBox1.SelectedIndex].ToString();
string tlongdate = ListBox1.SelectedValue.ToString();
TextBox1.Text = tsource; //local to menu.aspx
Images gi = new Images();
gi.GetImages(tlongdate, tsource);
}

Code in images.aspx.cs:
public void GetImages(string LongDate, string Source)
{
Images mn = new Images();
//this text box is on images.aspx
mn.TextBox1.Text = LongDate; //here is the error
}

Thanks,
Evan R. Hicks


Nov 19 '05 #3

P: n/a
You're on the right track.
You can output a bit of client side javascript to do the trick.
Something like this should get you started:

Response.Write("<script language=javascript>parent.FRAMENAME.location
= 'whatever.aspx?MyParameter=4'</script>")

You could also use the RegisterClientScriptBlock or
RegisterStartupScript functions to do this.
Here's more info on these:

http://msdn.microsoft.com/library/de...BlockTopic.asp
http://msdn.microsoft.com/library/de...riptBlockTopic

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net


"Evan" <Ev**@discussions.microsoft.com> wrote in message
news:0F**********************************@microsof t.com...
That answers my question about my current behavior. The problem is that I
am
converting an existing site to .NET and it uses two asp pages in separate
frames. Is there a way that a button click on menu.aspx can load
images.aspx
in another frame? I can pass the data on the url line for the
communication
between the pages. I was thinking maybe Response.Redirect but there is no
option for a target frame.

Thanks,
Evan

"Steve C. Orr [MVP, MCSD]" wrote:
You must understand that menu.aspx and images.aspx do not exist on the
server at the same instance in time, therefore they cannot communicate
directly with each other.
Instead you need to use other techniques, such as client side code and/or
Session state to pass data between the pages.
This is one reason I try to avoid frames with ASP.NET; it's usually too
complex to be worth it.
Instead it's generally a better idea to use User Controls to divide up
logical sections of your pages.

Here's more info:
http://msdn.microsoft.com/library/de...ercontrols.asp
http://msdn.microsoft.com/library/de...ercontrols.asp
http://msdn.microsoft.com/library/de...ebControls.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"Evan" <Ev**@discussions.microsoft.com> wrote in message
news:0F**********************************@microsof t.com...
>I have a web page with 2 frames. The left frame is running menu.aspx
>and
>the
> right frame is running images.aspx. When a selection is made in
> menu.aspx
> I
> call a method in images.aspx and pass a variable. The intention is
> that
> images.aspx will take the variable and load images into its frame (the
> right
> one) based on the variable passed. What actually happens is the method
> runs
> in the left frame and ruturns the error "Object reference not set to an
> instance of a oblect" in the left frame. Nothing happens in the right
> frame.
> The exception is pointing to the line of code located in
> images.aspx.cs.
> How do I make the code in images.aspx.cs affect the frame it is in
> instead
> of
> the frame it is called from?
>
> Code in menu.aspx.cs:
> private void Button1_Click(object sender, System.EventArgs e)
> {
> string tsource = Startup.MainSource[ListBox1.SelectedIndex].ToString();
> string tlongdate = ListBox1.SelectedValue.ToString();
> TextBox1.Text = tsource; //local to menu.aspx
> Images gi = new Images();
> gi.GetImages(tlongdate, tsource);
> }
>
> Code in images.aspx.cs:
> public void GetImages(string LongDate, string Source)
> {
> Images mn = new Images();
> //this text box is on images.aspx
> mn.TextBox1.Text = LongDate; //here is the error
> }
>
> Thanks,
> Evan R. Hicks


Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.