Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

Pasquale Esposito

Perugia - Italy

http://www.geocities.com/espositosoftware

Posted

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")

Proudly a Palestinian

Microsoft ASP.NET MVP

My Blog: wessamzeidan.net

Posted

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

Posted

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!

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.

Posted

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>

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.

  • 4 months later...
Posted

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

Read the Fovean Chronicles

Because you just can't spend your whole day programming!

Posted
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.
Posted

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

Read the Fovean Chronicles

Because you just can't spend your whole day programming!

Posted

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.

Posted

   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

Posted
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.
Posted
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

Read the Fovean Chronicles

Because you just can't spend your whole day programming!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...