Client side code and server controls.

G

Guest

Gang
I have an ASP.NET page with a series of datagrids on in it. I also have an html button control (on the same page) that runs client side script to display a modal dialog box (window.showModalDialog) . when this modal dialog returns, i want a couple of datagrids on the page to refresh their contents. does anyone know a good way to handle this?
 
K

Ken Cox [Microsoft MVP]

Hi Patrick,

Do you really need to use an HTML button? A server-side button can be made
to do what you need quite nicely. You add the javascript to the onclick
attribute and return true. The page will refresh itself!

Here's a little demo that uses a label and a button. Notice how the time on
the label updates on the refresh. Grids would do about the same
refresh-wise.

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
Label1.Text = Now.ToLongTimeString
Dim sb As New System.Text.StringBuilder
sb.Append("javascript:window.showModalDialog")
sb.Append("('http://authors.aspalliance.com/kenc/',")
sb.Append(" '','');return true;")
Button1.Attributes.Add("onclick", sb.ToString)
End Sub


<form id="Form1" method="post" runat="server">
<P>
<asp:Label id="Label1" runat="server">Label</asp:Label></P>
<P>
<asp:Button id="Button1" runat="server" Text="Pop"></asp:Button></P>
</form>

Ken
 
G

Guest

ok...so far so good. thanks. i have another question. the first time the window that is spawned (through the call to showModalDialog), the Session.SessionID value (Page_Load and ispostback is false) is different from all subsequent reloads of that page. after the first Page_Load the sessionID value remains the same. This is important because on that first call I am caching a couple of datasets. These are lost on the next Page_Load because the Session object has changed. Any ideas as to how I can prevent the Session object from changing between the initial page load and all other reloads?

----- Ken Cox [Microsoft MVP] wrote: -----

Hi Patrick,

Do you really need to use an HTML button? A server-side button can be made
to do what you need quite nicely. You add the javascript to the onclick
attribute and return true. The page will refresh itself!

Here's a little demo that uses a label and a button. Notice how the time on
the label updates on the refresh. Grids would do about the same
refresh-wise.

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
Label1.Text = Now.ToLongTimeString
Dim sb As New System.Text.StringBuilder
sb.Append("javascript:window.showModalDialog")
sb.Append("('http://authors.aspalliance.com/kenc/',")
sb.Append(" '','');return true;")
Button1.Attributes.Add("onclick", sb.ToString)
End Sub


<form id="Form1" method="post" runat="server"><P><asp:Label id="Label1" runat="server">Label</asp:Label></P><P><asp:Button id="Button1" runat="server" Text="Pop"></asp:Button></P></form>

Ken
 

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

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top