Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > modal popup window help

Reply
Thread Tools

modal popup window help

 
 
Mel
Guest
Posts: n/a
 
      03-16-2009
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
 
Reply With Quote
 
 
 
 
MLightsOut
Guest
Posts: n/a
 
      03-30-2009
On Mar 16, 4:44*pm, "Mark Rae [MVP]" <m...@markNOSPAMrae.net> wrote:
> "Mel" <MLights...@gmail.com> wrote in message
>
> news:a43b24f4-5fab-4829-9289-...
>
> > I ALWAYS struggle with these, sorry. *Can anyone help me?

>
> 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/ajaxcontrolt...lpopup/modalpo...
>
> All of your current problems will simply disappear, and you'll be standards
> compliant.
>
> > Dim strscript As String = "<script language=javascript>

>
> 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">
>
> --
> Mark Rae
> ASP.NET MVPhttp://www.markrae.net


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.
 
Reply With Quote
 
 
 
 
MLightsOut
Guest
Posts: n/a
 
      03-30-2009
On Mar 30, 9:02*am, "Mark Rae [MVP]" <m...@markNOSPAMrae.net> wrote:
> "MLightsOut" <MLights...@gmail.com> wrote in message
>
> news:c521f789-4d9b-4332-8aa9-...
>
>
>
>
>
> >> 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/ajaxcontrolt...lpopup/modalpo...

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

>
> > 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.

>
> 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>
<aspanel
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>
</
aspanel>
&nbsp;
</
ItemTemplate>
<ItemStyle
Wrap="False" />
</
asp:TemplateField>
 
Reply With Quote
 
MLightsOut
Guest
Posts: n/a
 
      03-30-2009
On Mar 30, 10:10*am, "Mark Rae [MVP]" <m...@markNOSPAMrae.net> wrote:
> "MLightsOut" <MLights...@gmail.com> wrote in message
>
> news:8249325b-08eb-41f5-8df8-...
>
> >> How have you constructed the GridView? Are you doing in-place editing
> >> e.g.
> >> with an Edit button?

>
> > 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.

>
> 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...
>
> --
> Mark Rae
> ASP.NET MVPhttp://www.markrae.net


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...
 
Reply With Quote
 
MLightsOut
Guest
Posts: n/a
 
      03-30-2009
On Mar 30, 10:59*am, "Mark Rae [MVP]" <m...@markNOSPAMrae.net> wrote:
> "MLightsOut" <MLights...@gmail.com> wrote in message
>
> news:46795a6b-6589-44c9-be30-...
>
> > 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

>
> I don't understand - how can you not see the GridView from code-behind...?
>
> --
> Mark Rae
> ASP.NET MVPhttp://www.markrae.net


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.
 
Reply With Quote
 
MLightsOut
Guest
Posts: n/a
 
      03-30-2009
On Mar 30, 11:38*am, MLightsOut <MLights...@gmail.com> wrote:
> On Mar 30, 10:59*am, "Mark Rae [MVP]" <m...@markNOSPAMrae.net> wrote:
>
> > "MLightsOut" <MLights...@gmail.com> wrote in message

>
> >news:46795a6b-6589-44c9-be30-....

>
> > > 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

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

>
> > --
> > Mark Rae
> > ASP.NET MVPhttp://www.markrae.net

>
> 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to close a parent modal window when child modal window opens? gopal srinivasan Javascript 0 11-05-2004 05:59 AM
New Popup Window from an existing Popup Window Raffi Javascript 4 08-12-2004 01:21 PM
post the form data in modal window and close the modal window. Matt HTML 1 06-01-2004 08:22 PM
post the form data in modal window and close the modal window. Matt Javascript 0 06-01-2004 07:47 PM
Re: Popup Modal Window Khutso ASP .Net 2 08-04-2003 09:03 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57