How to pass a value to a popup page

esposito

Centurion
Joined
Jul 11, 2003
Messages
103
Location
Perugia - Italy
Hello, I need to pass a value stored in a Label from one page to another and I only know how to do it if the receiving page is not a popup one. The VB.NET code I use is the following:

Code:
    Dim MyValue As String
    MyValue = lblValue.Text
    Response.Redirect ("newpage.aspx?ID=" & MyValue)

I can also open a popup page using the following javascript:

Code:
    Dim sScript As String
    sScript = "<script>window.open('newpage.aspx','','height=100','width=100','scrollbars=no');<" & "/script>"
    Response.Write(sScript)

What I can't do is modify the javascript code above in such a way as to get the value from the Label and pass it to the popup page.

Any help will be greatly appreciated.
 
I usually create a global value and pass it to that

You can also use a cookie, write to the cookie from the main page and then read it from the popup
 
Code:
Dim sScript As String
    sScript = "<script>window.open('newpage.aspx?ID=" & MyValue &"','','height=100','width=100','scrollbars=no');<" & "/script>"
    Response.Write(sScript)

You can then read the value in the popup page as you do in any normal page using Request.QueryString("ID")
 
esposito,

Quick question, I note how you use the Response.Redirect("newpage.aspx?ID=" & MyValue) and I am wondering, once you have passed the "MyValue" to the target page (within the URL), how you utilise the value in the target page.

Reading your post showed me how to partly solve a similar problem I was experiencing, I was wondering if you could inform me of how to finally nail the whole problem.

Thanks
 
as I said in the last post, use Request.QueryString("MyValue") in the target page

for example, in the page load event of the target page

Dim x As String=Request.QueryString("MyValue")
 
no, no, no, no, no!

you guys are forgetting the strength of javascript - implied properties. . .

put this in a page, HTMLPage1.htm

PHP:
function newWindow()
 {
  var wnd = open('HTMLPage2.htm');
  wnd.theLabelToSet.innerHTML = document.all.aLabel.innerHTML;
 }
 </script>
 <body>
  <div id="aLabel">the text</div>
  <button onclick="newWindow();">click me</button>
 </body>

put this in HTMLPage2.htm
PHP:
<body>
<div id=theLabelToSet></div>
 </body>

check it out!
 
oh yeah. . . it even works for variables -

use this code for HTMLPage2.htm:

PHP:
<script> 
var theLabelToSet;
</script> 
<body>
 <button onclick="alert(theLabelToSet);">click me</button>
</body>
 
How do you get this to pop up while you are running another process, tho?

I am trying for a popup that says, "Wait while I am doing my thing" while I query a large table

I tried putting it in the postback in the form_load, but it doesn't execute until after the event (a button push) is done
 
TheWizardofInt - You are talking about a wait page, one way is to put your logic in the render sub, do a bunch or response.writes and flushes, that is writing any messages, javascripts, whatever. One problem with this is if the operation is very long running, then you keep the client connected to your web server, you have ot deal with dissconnect issues, rollbacks in your transactions, etc.. The web isnt meant for this type of constant connected state.
 
Kahluah - I am aware of all of that

However, a wait of 30 seconds isn't going to hurt anyone, unless the end user starts clicking all of the other buttons on the page because 'nothing happened'

The problem with putting the popup in the render sub is that it doesn't execute until all of the actions on the page are done
 
Code:
However, a wait of 30 seconds isn't going to hurt anyone

When you said queryin a large table, i assumed you meant more than 30 seconds, but you never know. Staying connected to a web server for 30 secs is a problem with some of my clients who are on crappy dialups and home wireless networks that come in and out of range.
 
I am guessing, then, that you have no idea on how to do this?

Because that is what I am looking for: information on how to pop up a form that exists while the process is running, then goes away when it is done
 
Code:
    Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
        Response.Write("<script language='javascript'>var win = window.open('waitingpage.htm','','');</script>")
        Response.Flush()
        'Simulate long running process
        System.Threading.Thread.Sleep(10000)
        Response.Write("<script language='javascript'>win.close();</script>")
        Response.Flush()
    End Sub
 
Forgot to mentin, you might want to trap the begning html and ending html and write those accordingly, so the end result is a nice formated html page.
 
When I add that code (after reforming the html for size and no task bars) all it does is lock the page up and prevent all of the other objects from loading
 
Yes, in your codebehind. You are overriding the render sub. I'm guessing the lock up you are talking about is the thread.sleep, dunno tho, if you yhad stuff on your .aspx page, you need to trap the begingin of it and the end html and write those before and after your javascript calls. As i said before, this is not the prettiest way of doing a wait page, but it works for what you asked, even if a few workarounds are necessary. I read on a msdn article, they do the same thing by overridng the render sub, but instead they wrote the status of the progress on the actual page by setting the InnerHtml of a div. Cant find thta article tho.
 
kahlua001 said:
Yes, in your codebehind. You are overriding the render sub. I'm guessing the lock up you are talking about is the thread.sleep, dunno tho, if you yhad stuff on your .aspx page, you need to trap the begingin of it and the end html and write those before and after your javascript calls. As i said before, this is not the prettiest way of doing a wait page, but it works for what you asked, even if a few workarounds are necessary. I read on a msdn article, they do the same thing by overridng the render sub, but instead they wrote the status of the progress on the actual page by setting the InnerHtml of a div. Cant find thta article tho.

Ok, with that I can do some research and figure it out

Thanks for sending me down the right road
 
Back
Top