modal popup window help

M

Mel

I ALWAYS struggle with these, sorry. Can anyone help me? My parent
window has some server side vb code to open the Modal popup window.
My modal popup window appears and I want to do some server-side
processing before returning to the parent window. I also need to pass
one value back. How to accomplish this? Here is what I have so
far...

Here is my parent window code:
'image button exists on parent window. Clicking the button
displays the modal dialog (called notes).
Protected Sub imgNote_Click(ByVal sender As Object, ByVal e As
System.Web.UI.ImageClickEventArgs)
Dim windowAttribs As String
Dim lngWidth As Long = 1440, lngHeight As Long = 900

Dim imageButton As ImageButton = sender
Dim tableCell As TableCell = imageButton.Parent
Dim row As GridViewRow = tableCell.Parent

windowAttribs = "dialogwidth=" & lngWidth & "px;" & _
"dialogheight=" & lngHeight & "px;" & _
"Edge: Raised; center: Yes;help: No; resizable: Yes;
status: No"

'use a modal dialog - pass FAB NUM and TASK ID
ScriptManager.RegisterStartupScript(Me, GetType(String),
"OpenWindowScript", "window.showModalDialog('Notes.aspx?p1=" &
txtFabNum.Text.ToString & "&p2=" & row.RowIndex + 1 & "','','" +
windowAttribs + "');", True)
End Sub

'this is my popup window OK button
Protected Sub cmdOK_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cmdOK.Click

'server side processing is done here (which writes the notes
to the database).

Session("Notes") = txtNote.Text.ToString 'this is the data I
want to pass back to parent window

'THIS CODE DOES NOT WORK. HOW DO I CLOSE A MODAL DIALOG?
Dim strscript As String = "<script
language=javascript>window.close();</script>"
If (Not ClientScript.IsStartupScriptRegistered
("clientScript")) Then
ClientScript.RegisterStartupScript(Page.GetType(),
"clientScript", strscript)
End If
End Sub
 
M

MLightsOut

Do yourself a *HUGE* favour and abandon the completely non-standard
showModalDialog stuff.

Use an AJAX modal popup extender instead:http://www.asp.net/ajax/ajaxcontroltoolkit/samples/modalpopup/modalpo...

All of your current problems will simply disappear, and you'll be standards
compliant.


The language attribute of the <script /> tag has been deprecated for over 12
years! If you must do this, at least use:

<script type="text/javascript">

I am using the AJAX modal popup extender now. Now when I click on the
imgNote button in the GridView it will show my Panel1 data in a AJAX
modal popup window. My Panel1 contains another gridview, how do I
update the gridview in the popup window to display the correct
information? How do I pass this information to the popup? Any help
would be greatly appreciated.
 
M

MLightsOut

Exactly the same way you would update it if it weren't inside an AJAX modal
popup - all the popup does is unhide a floating div to display its contents.

How have you constructed the GridView? Are you doing in-place editing e.g..
with an Edit button?

--
Mark Rae
ASP.NET MVPhttp://www.markrae.net- Hide quoted text -

- Show quoted text -

No I am not using an edit button. The imgNote button resides in the
Item Template of the parent window's GridView control. When the user
clicks the imgNote button the AJAX modal popup extender will appear
and display another gridview (called gvNotes which resides inside
Panel1) containing all of the notes for that given task. So somehow I
would need to update those two querystring fields to the correct
values to show the correct note(s) in the gvNotes control. That is
where I am stuck.


<asp:TemplateField
HeaderText="Notes">

<EditItemTemplate>
</
EditItemTemplate>
<ItemTemplate>

<asp:TextBox ID="txtNote" runat="server" Height="20px"
TextMode="MultiLine" Text='<%# Bind("[Notes]")%>' Font-Names="Verdana"
Font-Size="Small" ReadOnly="True" Width="312px" ></
asp:TextBox><asp:ImageButton ID="imgNote" runat="server"
BorderStyle="Outset" BorderWidth="3px"

ImageUrl="~/images/Note.bmp" OnClick="imgNote_Click" ToolTip="Manage
Notes For This Task" />

<cc1:ModalPopupExtender ID="mpe" runat="server"
BackgroundCssClass="modalBackground" cancelcontrolid="cmdCancel"
dropshadow="true" okcontrolid="cmdOK" onokscript="onOk()"
popupcontrolid="Panel1" targetcontrolid="imgNote">
</
cc1:ModalPopupExtender>
<asp:panel
ID="Panel1" runat="server" BorderStyle="Outset" BorderWidth="2px">
<table
border="0" cellpadding="4" cellspacing="4" style="font-size: small;
font-family: Verdana; background-color: white;">

<tr>

<td colspan="2" style="background-color: silver">

<asp:Label ID="lblNoteHistory" runat="server" Text="Note History"></
asp:Label><br />

<asp:GridView ID="gvNotes" runat="server" AllowPaging="True"
AllowSorting="True"

AutoGenerateColumns="False" CellPadding="4" DataKeyNames="Fab #,Task
Order,Note ID"

DataSourceID="sqlTaskNotes" EmptyDataText="No Records Exist."
EnableSortingAndPagingCallbacks="True"

ForeColor="#333333">

<RowStyle BackColor="#E3EAEB" />

<Columns>

<asp:BoundField DataField="Note ID" HeaderText="ID" ReadOnly="True"
SortExpression="Note ID" />

<asp:BoundField DataField="Note Date" DataFormatString="{0:d}"
HeaderText="Date"

HtmlEncode="False" SortExpression="Note Date" />

<asp:BoundField DataField="Note" HeaderText="Note"
SortExpression="Note" />

</Columns>

<FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />

<PagerStyle BackColor="Maroon" ForeColor="White"
HorizontalAlign="Center" />

<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True"
ForeColor="#333333" />

<HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />

<EditRowStyle BackColor="#7C6F57" />

<AlternatingRowStyle BackColor="White" />

</asp:GridView>

</td>
</
tr>

<tr>

<td colspan="2">

<asp:Label ID="Label1" runat="server" Text="Add a New Note"></
asp:Label>&nbsp; -&nbsp;

<asp:Label ID="lblDate" runat="server"></asp:Label><br />

<asp:TextBox ID="TextBox1" runat="server" Height="128px"
TextMode="MultiLine" Width="672px"></asp:TextBox><br />

<asp:Button ID="cmdAddNewNote" runat="server" Text="Add New Note"
Visible="False"

Width="152px" /></td>
</
tr>

<tr>

<td style="padding-right: 20px; text-align: right; height: 40px;">

<asp:Button ID="cmdOK" runat="server" Height="26px" Text="Done"
Width="128px" /></td>

<td style="padding-left: 20px; height: 40px;">

<asp:Button ID="cmdCancel" runat="server" Height="26px" Text="Cancel"
Width="128px" /></td>
</
tr>
</
table>

<asp:SqlDataSource ID="sqlTaskNotes" runat="server" ConnectionString="<
%$ ConnectionStrings:MYSQLSrv Access DbConnectionString %>"

SelectCommand="SELECT * FROM [PMJ TASK NOTES] WHERE (([Task Order] =
@Task_Order) AND ([Fab #] = @column1)) ORDER BY [Task Order], [Note
ID]">

<SelectParameters>

<asp:QueryStringParameter DefaultValue="12345" Name="column1"
QueryStringField="p1"

Type="String" />

<asp:QueryStringParameter DefaultValue="1" Name="Task_Order"
QueryStringField="p2"

Type="Int32" />
</
SelectParameters>
</
asp:SqlDataSource>
</
asp:panel>
&nbsp;
</
ItemTemplate>
<ItemStyle
Wrap="False" />
</
asp:TemplateField>
 
M

MLightsOut

Ah, I see - apologies, but I don't know the answer, as I never use these
SqlDataSource "training wheels" controls.

I would imagine that you will need to modify the SelectCommand as part of
the AJAX callback and then rebind the GridView...

Hopefully someone else will be of more help to you...

Yes, I would need to update the select command. I don't know where I
would to that though; I can't see the gvNotes GridView from code-
behind and don't know how I would access it from Javascript either. I
willl keep searching for a solution...
 
M

MLightsOut

I don't understand - how can you not see the GridView from code-behind...?

What I meant by that is in my vb code if I type gvNotes it does not
recognize that control. It doesn't appear in intellisense. I suppose
because gvNotes is buried inside another GridView control I would need
to call it differently. gvNotes is in the ItemTemplate and inside a
panel called Panel1.

To work around the select command issue I created 2 more textboxes in
my item template where my modal popup extender resides. I bound each
textbox to the fields I need. My popup window gridview which is
called gvNotes is bound to that "cheesy" SQL data source so I set each
Sql data source parameter to those text boxes. This works and at
least shows the correct data in my pop-up window. Not sure if this is
the best way but it does work. The goal of my popup window is to
allow the user to view or add a new note. Viewing works, now I just
need to figure out how I allow the user to add a new note record to
the database when they click Ok.
 
M

MLightsOut

What I meant by that is in my vb code if I type gvNotes it does not
recognize that control.  It doesn't appear in intellisense.  I suppose
because gvNotes is buried inside another GridView control I would need
to call it differently.  gvNotes is in the ItemTemplate and inside a
panel called Panel1.

To work around the select command issue I created 2 more textboxes in
my item template where my modal popup extender resides.  I bound each
textbox to the fields I need.  My popup window gridview which is
called gvNotes is bound to that "cheesy" SQL data source so I set each
Sql data source parameter to those text boxes.  This works and at
least shows the correct data in my pop-up window.  Not sure if this is
the best way but it does work.  The goal of my popup window is to
allow the user to view or add a new note.  Viewing works, now I just
need to figure out how I allow the user to add a new note record to
the database when they click Ok.

So, does anyone know if I can use an AJAX Modal Popup window to add
records to the GridView? Or any pointers on how to do that? The
GridView I want to update is the one contained within the Modal Popup
window.
 

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,968
Messages
2,570,154
Members
46,702
Latest member
LukasConde

Latest Threads

Top