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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accessing arguments passed to a modal form in Page_Load 1

Status
Not open for further replies.

redav

Programmer
Mar 20, 2001
55
GB
I have a main web page which opens a modal web page and passes an integer argument into the modal page:-

Code:
function open_modal(intSearchType) 
{
	var WinSettings = "status:no;dialogWidth:520px;dialogHeight:250px;dialogHide:true;help:no;scroll:no";
	
	window.showModalDialog("GeneralItem.aspx", intSearchType, WinSettings);

I then have the following javascript funtion to set the modal argument into a hidden html field so that I can access it:-

Code:
function do_init()
{		
	var intSearchType = window.dialogArguments;	
	document.getElementById("pass_field").value  = intSearchType;
}

The above is run on the client like this:-

Code:
<BODY onload="do_init();" ms_positioning="GridLayout">

This all works great.

The problem I have is that I now need to access the passed argument in the modal forms Page_Load event. How can I access the value on the server before the page is generated and sent back to the browser because obviously the do_init function hasn't ran on the client so the value is not in the hidden field. I am just gettig to grips with this Client/Server stuff and the help would be much appreciated.

Many Thanks
 
u use a hidden field right?

set the following attribute:

<input type="hidden" ... runat="server"...>


now it becomes a Server control (be careful as to keep it outside any other .NET control).


once u do that:
function do_init()
{
var intSearchType = window.dialogArguments;
document.getElementById("pass_field").value = intSearchType;
document.forms[0].submit();
}



now u can use the variable in ASP.NET like so:

response.write(HiddenFieldName.Value)

Known is handfull, Unknown is worldfull
 

Thanks for the reply vbkris.

The hidden field is already a server control and once the value has been put in it I can access it in VB.NET with no problems.

The problem arises because I want to access the passed variable in the Page_Load event of the modal page. My understanding is that this runs on the server before the function do_init() is ran. Therefore the value hasn't been set in the hidden field yet.

I am new to this so I am probably missing something really obvious but I cannot see how to access the argument in the modal before the page has been sent back to the browser at least once.

Hope I have explained this better and thanks again for your assistance.

 
>>. My understanding is that this runs on the server before the function do_init() is ran. Therefore the value hasn't been set in the hidden field yet.


that is absolutely correct. may i know what u r trying to do?

Known is handfull, Unknown is worldfull
 
Sure

The modal web form is populated with data for the user to make a selection. The type of data the user is to select (i.e. clients, items, whatever) is identified with the variable intSearchType which is passed from the main form to the modal.

Hope I have explained that clearly. If not then let me know.

Thanks for the help
 
Could you simply pass the value through to the child page as a querystring as then you can access from your Page Load event (or have I mis0understood what you are trying to do)?


____________________________________________________________

Need help finding an answer?

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

 
Yep I might be able to do this.

If I pass the value through as a query string how do I access it in the Page_Load event?

Many Thanks
 
Request.Querystring("MyVariable")


____________________________________________________________

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