Is it possible?

M

Marc Robitaille

Hello,

I have a server button on my page. This button is use to open a serach page.
In the Page_Load event, I code this

If (Not Page.IsClientScriptBlockRegistered("clientScript")) Then
Page.RegisterClientScriptBlock("clientScript",
mpstrGetOpenSearchDialogScript)
End If

If Not IsPostBack Then
cmdSearch.Attributes.Add("onclick", "OpenSearchDialog();")
End If

Private Function mpstrGetOpenSearchDialogScript() As String

Dim strScript As String = ""

strScript += "<script language=""javascript"">" + Environment.NewLine
strScript += " function OpenSearchDialog()" + Environment.NewLine
strScript += " {" + Environment.NewLine
strScript += " var winSettings = 'center:yes;resizable:no;help:no;'" +
Environment.NewLine
strScript += " + 'status:no;dialogWidth:960px;dialogHeight:495px';" +
Environment.NewLine
strScript += " window.showModalDialog('frmSearch.aspx', '',
winSettings);" + Environment.NewLine
strScript += " }" + Environment.NewLine
strScript += "</script>" + Environment.NewLine
Return strScript

End Function

This code open a dialog window and it works perfectly. My problem is that I
need to set Session variables before the window opens. The server click
event of my button execute afther the window is close by the user. Is it
possible to set my session variables before the window is open when I click
on my search button?

Thank you!
Marc R
 
M

Mythran

Marc Robitaille said:
Hello,

I have a server button on my page. This button is use to open a serach
page. In the Page_Load event, I code this

If (Not Page.IsClientScriptBlockRegistered("clientScript")) Then
Page.RegisterClientScriptBlock("clientScript",
mpstrGetOpenSearchDialogScript)
End If

If Not IsPostBack Then
cmdSearch.Attributes.Add("onclick", "OpenSearchDialog();")
End If

Private Function mpstrGetOpenSearchDialogScript() As String

Dim strScript As String = ""

strScript += "<script language=""javascript"">" + Environment.NewLine
strScript += " function OpenSearchDialog()" + Environment.NewLine
strScript += " {" + Environment.NewLine
strScript += " var winSettings = 'center:yes;resizable:no;help:no;'" +
Environment.NewLine
strScript += " + 'status:no;dialogWidth:960px;dialogHeight:495px';" +
Environment.NewLine
strScript += " window.showModalDialog('frmSearch.aspx', '',
winSettings);" + Environment.NewLine
strScript += " }" + Environment.NewLine
strScript += "</script>" + Environment.NewLine
Return strScript

End Function

This code open a dialog window and it works perfectly. My problem is that
I need to set Session variables before the window opens. The server click
event of my button execute afther the window is close by the user. Is it
possible to set my session variables before the window is open when I
click on my search button?

Thank you!
Marc R

Not without a postback...but if you are just trying to get a small amount of
data to frmSearch.aspx (the new window) then you can just pass the
querystring, IE:

strScript += " window.showModalDialog('frmSearch.aspx?id=xxx', ...


HTH :)

Mythran
 
G

garethdjames

You could use an XmlHTTPRequest object on the client to do a server
call, this would call a server side aspx page which sets the session
variable,

or you could open a page that sets the session variable, then redirects
to the search page
 
B

billmiami2

Which session variables do you need to set? Why can't you set them
before the user even gets a chance to click on the button to open the
search dialog?

Bill E.
Hollywood, FL
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,053
Messages
2,570,431
Members
47,075
Latest member
TysonV438

Latest Threads

Top