Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing variables from vbscirpt 2

Status
Not open for further replies.

pgstein

Programmer
Jul 27, 2005
33
0
0
US
I am creating an ASP.NET project, and what I need to do is have the user click a button, he is then prompted with a date, and then he is transfered to the correct page based on his input.

I am using VBScript to generate the input box, but the problem I am having is when I use "window.open" in VBScript, the ASP.NET page just refreshes itself. Is there or fix for this? and if not, can I pass variables from my VBScript back to my ASP.NET page?

Thanks alot, some of my code is posted below, any help is greatly appreciated!
Paul

This is my ASP.NET Code:
Code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Button1.Attributes.Add("onClick", "return test(""mnthlyaverage.aspx"");")
End Sub

This is my VBScript function:
Code:
function test(pagename)
        dim startdate
	dim enddate
        Dim URL

	startdate=InputBox("Enter Start:")
	enddate=InputBox("Enter End:")
	URL = pagename & "?startdate=" & startdate & "&enddate=" & enddate
	window.open(URL)
end function
 
If I set the Visible=False property the routine does not work.
That will be because the control does not get rendered to the page at all. An alternative to setting a zero height and width is to add a display attribute to it e.g.
Code:
TextBox1.Attributes.Add("style", "display: none;")



____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
thanks both of you, Ill check it out monday morning.
 
pgstien: as a final (and I really appreciate ca8msm reading through the thread and catching this); another way to impliment his suggestion is as follows This may be obvious but I'll put it up anyway (one I suppose could ask which way might be more efficient? perhaps only a fraction of ms diff).

<asp:Textbox id="Textbox1" runat="server" style="display:none;"/>
 
Yes, setting the style in the HTML portion of the page would do exactly the same (as would giving it a CSSClass and setting the display to none in the class). I guess it's just down to personal preference which method you use, but I would probably go with the hidden HTML input.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top