esposito Posted October 3, 2004 Posted October 3, 2004 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: Dim MyValue As String MyValue = lblValue.Text Response.Redirect ("newpage.aspx?ID=" & MyValue) I can also open a popup page using the following javascript: 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. Quote Pasquale Esposito Perugia - Italy http://www.geocities.com/espositosoftware
TheWizardofInt Posted October 3, 2004 Posted October 3, 2004 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 Quote Read the Fovean Chronicles Because you just can't spend your whole day programming!
wessamzeidan Posted October 4, 2004 Posted October 4, 2004 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") Quote Proudly a Palestinian Microsoft ASP.NET MVP My Blog: wessamzeidan.net
anpalmer Posted October 4, 2004 Posted October 4, 2004 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 Quote
wessamzeidan Posted October 5, 2004 Posted October 5, 2004 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") Quote Proudly a Palestinian Microsoft ASP.NET MVP My Blog: wessamzeidan.net
HJB417 Posted October 6, 2004 Posted October 6, 2004 URL QueryString or Session or HttpPost though you're not limited to those three choices. Quote
Joe Mamma Posted October 6, 2004 Posted October 6, 2004 no, no, no, no, no! you guys are forgetting the strength of javascript - implied properties. . . put this in a page, HTMLPage1.htm 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 <body> <div id=theLabelToSet></div> </body> check it out! Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
Joe Mamma Posted October 6, 2004 Posted October 6, 2004 oh yeah. . . it even works for variables - use this code for HTMLPage2.htm: <script> var theLabelToSet; </script> <body> <button onclick="alert(theLabelToSet);">click me</button> </body> Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
TheWizardofInt Posted February 24, 2005 Posted February 24, 2005 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 Quote Read the Fovean Chronicles Because you just can't spend your whole day programming!
kahlua001 Posted February 24, 2005 Posted February 24, 2005 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. Quote
TheWizardofInt Posted February 24, 2005 Posted February 24, 2005 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 Quote Read the Fovean Chronicles Because you just can't spend your whole day programming!
kahlua001 Posted February 24, 2005 Posted February 24, 2005 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. Quote
TheWizardofInt Posted February 24, 2005 Posted February 24, 2005 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 Quote Read the Fovean Chronicles Because you just can't spend your whole day programming!
kahlua001 Posted February 24, 2005 Posted February 24, 2005 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 Quote
kahlua001 Posted February 24, 2005 Posted February 24, 2005 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. Quote
TheWizardofInt Posted February 24, 2005 Posted February 24, 2005 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 Quote Read the Fovean Chronicles Because you just can't spend your whole day programming!
kahlua001 Posted February 24, 2005 Posted February 24, 2005 Works for me. Not sure what you mean by locks up the page. Quote
TheWizardofInt Posted February 24, 2005 Posted February 24, 2005 Do you just add it to your code behind, or do you put it in someplace specific? Quote Read the Fovean Chronicles Because you just can't spend your whole day programming!
kahlua001 Posted February 24, 2005 Posted February 24, 2005 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. Quote
TheWizardofInt Posted February 24, 2005 Posted February 24, 2005 Yes' date=' 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.[/quote'] Ok, with that I can do some research and figure it out Thanks for sending me down the right road Quote Read the Fovean Chronicles Because you just can't spend your whole day programming!
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.