Showing posts with label user. Show all posts
Showing posts with label user. Show all posts

Wednesday, March 28, 2012

Modal Popup and WebPages ?

Is there any way to show different webpages inside modal popup or there is some different way ? From different webpages I mean, based on user selection .....

You can use the Dynamic* propertied of the modalpopup to load the content dynamically via a web service. The DynamicContextKey allows you to provide context to the web method that allows you to load different content depending on the value passed in.

You could also programmatically control the display of the modalpopup by using a hidden button as the TargetControlID and calling Show() manually. This allows you to postback and load the content according to the user selection.


Can you please provide an example which I can follow ?


The easiest way I can think of, is using an iframe inside the modal popup and setting it's src before showing popup.

Modal Popup events not responding

I have a modal popup control that is created dynamically along with various other controls on Page_Init. Actually it's a user control created dynamically, and part of that user control is the modal popup.

Inside the modal popup is basically just a grid view with some hyperlink columns. The problem is that none of the links ever seem to respond. The popup is shown by a serverside call to the Show() method.

I experimented and put a few buttons and various other controls, and while the button animates like it's been pressed, no server code fires. This happens reguardless of the control type; radiobuttons won't even check. This occurs in controls both inside and outside of the gridview.

Anyone run into something similar with a dynamically created modal popup?

When the controls are being created dynamically, are you attaching events to the objects that will be posting back (ie the modal popup window). I have a similar situation where I have a user control that dynamically creates buttons. The buttons did not work until I added a event handler once I created them. When you add conntrols to a page, this is done automatically, but If you create a control dynamically, you must tell the page what to do with its events when they are raised. Make sence?

-Alan


Yes, it makes sense. The standard events that are tied into the controls, Page_Load, Page_PreRender, etc. all fire fine at the right times. It's only UI events like Click that don't respond on the server side. I can get them to execute javascript (of course) but I'd like to avoid having to hack together a callback function just to get a button working. Besides wiring the buttons/links/etc with events directly from the aspx page, I've tried adding the controls dynamically also (within the dynamically created user control housing the modalpopup) and then wiring them to the events.

Adding the controls that way in the user control's Load, and Init events both yield the same results. The code gets run and the controls get created, but they do not respond to UI events.

Modal Popup disappears on any post back

Currently I have User Control that has radio button list that changes options on the user control, some text boxes and a button that updates a list box with options selected within the user control. Any object that causes a post back seems to cause my modal popup control to disappear. How can I better control this? There are three postback operations that the user will go through in order for thems to get the correct selection - which should cause the modal to disappear and an update to happen to the calling page controls.

Any suggestions?

How about putting the UserControl inside an UpdatePanel if it isn't? Is this what you are trying to do? (The WebUserControl you'll have to supply.)

<%@. Page Language="C#" %><%@. Register src="http://pics.10026.com/?src=WebUserControl.ascx" TagName="WebUserControl" TagPrefix="uc1" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <script type="text/javascript"> function Show() { $get('WC').style.visibility = 'visible'; } function Hide() { $get('WC').style.visibility = 'hidden'; } </script> <button id="show" onclick="Show()"> show</button> <button id="hide" onclick="Hide()"> hide</button> <div id="WC" style="visibility: hidden"> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <uc1:WebUserControl ID="WebUserControl1" runat="server" /> </ContentTemplate> </asp:UpdatePanel> <button id="close" onclick="Hide()">close</button> </div> </div> </form></body></html>

I do have my user control within the UpdatePanel, currently. Within my user control there are database queries and options (basically its a search utility that give the user multiple options for searching the database to find the correct record). Once they have filled in their options within the search utility they are given a listbox (still within my user control) to select a record. Once the record is selected the calling page gets a control updated with the record ID which then causes a textchanged event that pulls up that record detail.

I wanted to utilize the modal popup extender so that when they search they can not horse around on the calling page. I do have have a version of this working with showing and hiding the update panel directly - however the modal popup extender (still using the atlas control) seemed to be a better option for this type of implementation.

By the way thanks so much for your quick response...


I decided it might be easier to give you my page code: Keep in mind that the problem is the post backs within my User Control. Any post back within the User Control itself cause the Modal Popup to become unmodal...Tongue Tied

1<%@. Page Language="VB" AutoEventWireup="True" %>23<%@. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>4<%@. Register src="http://pics.10026.com/?src=PagesAndControls_View/SiteSelection.ascx" TagName="SiteSelection"5 TagPrefix="uc1" %>6<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">78<script runat="server">910 Protected Sub OkButton_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs)11 Label1.Text = "OK Button Clicked"12 Me.txtSiteID.Text = "OK Button"13 Dim myPopUp As ModalPopupExtender = Me.ModalPopupExtender114 myPopUp.Hide()15 End Sub1617 Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)18 Label2.Text = "Other Button Clicked"19 Label1.Text = "Other Button Clicked"20 End Sub21 Protected Sub myTestScript()22 Label2.Text = "text script initiated"23 End Sub24</script>2526<html xmlns="http://www.w3.org/1999/xhtml">27<head runat="server">28 <title>Test Selection Page29 </title>30</head>31<body>32 <form id="form1" runat="server">33 <asp:ScriptManager ID="ScriptManager1" runat="server">34 </asp:ScriptManager>35 <div>36 <asp:UpdatePanel ID="PagePanel" runat="server">37 <ContentTemplate>38 <asp:Label ID="Label1" runat="server" Text="Enter Site ID or Search:"></asp:Label>39 <asp:TextBox ID="txtSiteID" runat="server"></asp:TextBox>40 <asp:ImageButton ID="SearchButton" ImageUrl="~/images/search.jpg" runat="server" />41 <asp:Panel ID="Panel1" CssClass="modalPopup" runat="server" Style="display: none"42 Wrap="False">43 <uc1:SiteSelection ID="SiteSelection1" runat="server" />44 <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>45 <div align="center">46 <asp:ImageButton ImageUrl="~/images/checkmark2.jpg" ID="OkButton" runat="server"47 OnClick="OkButton_Click" />48 <asp:ImageButton ImageUrl="~/images/closebutton5.jpg" ID="CancelButton" runat="server" />49 </div>50 </asp:Panel>51<!--52 <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />53 -->54 <cc1:ModalPopupExtender ID="ModalPopupExtender1" TargetControlID="SearchButton" runat="server"55 PopupControlID="Panel1" BackgroundCssClass="modalBackground" DropShadow="true"56 CancelControlID="CancelButton" OkControlID="OkButton" />57 </ContentTemplate>58 </asp:UpdatePanel>59 </div>60 </form>61</body>62</html>

Are you using the latest ModalPopupExtender in the AJAX Control Toolkit release 61020?

http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=AtlasControlToolkit&ReleaseId=825


I'm pretty sure that I am. I thought maybe my modal popus was outdated, so I deinstalled the atlas and installed the ajax version just yesterday and the problem persisted


Hey.

Was any progress made on this? I'm experiencing the problems now too (with the December Futures, and latest Toolkit)

Thanks,
Chris


The way I fixed this modal problem was by defining a boolean property PopupOpen (and keeping it in session). In the pre_render of the control i call modalpopupextender.show if PopopOpen is true. By setting the property I can control whether the popup is Open (you can wrap this in a user-control).

Hope you get the idea,

Martijn


Thanks...

I just managed to figure it out a different way. I addedUpdateMode="conditional" to the UpdatePanel on the page. Works a treat!

Modal Popup extender doesnt work (fast enough?) if used in a user control?

I created a user web control containing a blue panel which will pop up when user clicks on a text box. I use Modalpopupextender for this purpose. It is very simple!

When I reuse this control in a page, the blue panel shows up for a fraction when the page is loaded. This is very annoying cause I basically can't create my own modal dialog box and reuse for different pages. Is this a bug in the toolkit or do I need to add something to my control?

Thanks

MY CONTROL:

<%@dotnet.itags.org.ControlLanguage="C#"AutoEventWireup="true"CodeFile="TestPopUpBox.ascx.cs"Inherits="Admin_Configuration_TestPopUpBox" %>

<%@dotnet.itags.org.RegisterAssembly="AjaxControlToolkit"Namespace="AjaxControlToolkit"TagPrefix="cc1" %>

<asp:PanelID="Panel1"runat="server"BackColor="Blue"Height="235px"Style="position: relative"

Width="556px"><asp:TextBoxID="TextBox1"runat="server"Style="position: relative"></asp:TextBox>

</asp:Panel>

PAGE:

<%@dotnet.itags.org.PageLanguage="C#"AutoEventWireup="true"CodeFile="Test.aspx.cs"Inherits="Admin_Configuration_Test" %>

<%@dotnet.itags.org.RegisterSrc="AddDeviceControl.ascx"TagName="AddDeviceControl"TagPrefix="uc1" %>

<%@dotnet.itags.org.RegisterSrc="TestPopUpBox.ascx"TagName="TestPopUpBox"TagPrefix="uc2" %>

<%@dotnet.itags.org.RegisterAssembly="AjaxControlToolkit"Namespace="AjaxControlToolkit"TagPrefix="cc1" %>

<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">

<headrunat="server">

<title>Untitled Page</title>

</head>

<body>

<formid="form1"runat="server">

<div>

<asp:ScriptManagerID="ScriptManager1"runat="server">

</asp:ScriptManager>

This is the page<br/>

<uc2:TestPopUpBoxID="TestPopUpBox1"runat="server"/>

</div>

</form>

</body>

</html>

<cc1:ModalPopupExtenderID="ModalPopupExtender1"runat="server"TargetControlID="TextBox1"PopupControlID="Panel1">

</cc1:ModalPopupExtender>

I found another post which solves my problem.

You have to add "display:none" attribute to the panel style. I guess the code in AJAX control takes some time to iterate through all the controls on the page to find and hide the target panel.

Monday, March 26, 2012

modal popup extender help

Hi I am having a problem with Modal Popup Extender control. I have two web user controls, sign in control and register control(I am not using the default controls provided by asp.net). On my start page if the user clicks on "Sign In" i want to show the sign in control in a popup. If the user clicks on "Register" i want to show the register control in a popup.

Now if i only have 1 modal popup extender(for sign in control), everything works fine as expected. But as soon as i add one more modal popup extender(for register control), both controls stop working.

Has anyone encountered a similar problem? Am i missing something?

Any help or tips will be great. Thank you for your time. -Sanjay.Maybe check for script errors during page load?

Modal Popup in Custom User Control

I'm creating a DotNetNuke Module (DNN v4.5.3).

I've successfully added the Modal Popup into the module, but when i open it up it doesn't center on the screen (it centers to the control, which partically makes sense), also the background Styles do no apply themselves when the modal is being shown.

Has anyone ran into this issue before?

Thanks in advance for any replys, i'll update this post if i figure things out.

SyntaxC4

I messed around with the positioning of this control forever yesterday. I could not get it to work either. I'm also using DNN 4.5.3. If you find a solution, please post it!

Thanks.


Hi SyntaxC4,

My understanding of your issue is that your ModalPopupExtender doesn't shown on the center of the screen and also it has css issues.If I have misunderstood, please feel free to let me know.

Please make sure that the ModalPopupExtender is not located in a frame or IFame. If the ModalPopupExtender is inside a IFame, it will shown at the center of the IFrame instead of the screen.

The css issue, you can refer to the samples which contains in the Ajax Control Toolkit's source code. Here is the section:

/*Modal Popup*/
.modalBackground {
background-color:Gray;
filter:alpha(opacity=70);
opacity:0.7;
}

.modalPopup {
background-color:#ffffdd;
border-width:3px;
border-style:solid;
border-color:Gray;
padding:3px;
width:250px;
}

I hope this help.

Best regards,

Jonathan


Thanks for the reply Jonathan, I should have included some code so i will do that now.

<ASP_CODE>

<asp:ModalPopupExtender ID="AddPopUp" runat="server" TargetControlID="AddRangeOpen" PopupControlID="AddRange" CancelControlID="AddCancel" PopupDragHandleControlID="AddRangeHandle" BackgroundCssClass="modalBG" /><asp:Panel ID="AddRange" runat="server" Style="display:none;" CssClass="modalWindow"> <table> <tr> <td colspan="2"> <asp:Panel ID="AddRangeHandle" runat="server" CssClass="title"> <asp:Label ID="HandleLabel" runat="server" Text="Add Shipping Range" /> </asp:Panel> </td> </tr> <tr> <td><asp:Label ID="RangeStartLabel" runat="server" Text="Range Start:" AssociatedControlID="RangeStart" /></td> <td><asp:TextBox ID="RangeStart" runat="server" /></td> </tr> <tr> <td><asp:Label ID="RangeStopLabel" runat="server" Text="Range Stop:" AssociatedControlID="RangeStop" /></td> <td><asp:TextBox ID="RangeStop" runat="server" /></td> </tr> <tr> <td><asp:Label ID="RangeValueLabel" runat="server" Text="Range Value:" AssociatedControlID="RangeValue" /></td> <td><asp:TextBox ID="RangeValue" runat="server" /></td> </tr> <tr> <td colspan="2"><asp:CheckBox ID="isRangePercent" runat="server" Text="Percentage:" TextAlign="Left" /></td> </tr> <tr> <td colspan="2"><asp:CheckBox ID="isActive" runat="server" Text="Active:" TextAlign="Left" /></td> </tr> <tr> <td colspan="2" align="right"><asp:Button ID="AddSave" runat="server" Text="Save" OnClick="AddSave_Click" /><asp:Button ID="AddCancel" runat="server" Text="Cancel" /></td> </tr> </table></asp:Panel>

</ASP_CODE>

<CSS_STYLES>

/************************//****/ AJAX MODAL/****//************************/.modalBG{ background-color: #666; Filter:alpha(opacity=70); opacity:0.7;}.modalWindow{ background-color: #FFF; border: solid3px #333; padding:3px;}.title{ background-color: #5D7B9D; color: #FFF; font-weight:bold; text-align:center;}

</CSS_STYLES>

This code is in a Control, not a page. I think this is what is causing the issue. As the modal pops up within the confinements of the control and not to the center of the page.

Thanks for any more information in advance.

SyntaxC4


I've had this same issue and I believe you can add this to your stylesheet.

.modalWindow

{
background-color: #FFF;
border: solid3px #333;
padding:3px;
position: absolute;
left: 50%;
top: 50%;
}
 
I'm not sure if you need the position: absolute; or not though.
 

sstewart:

I've had this same issue and I believe you can add this to your stylesheet.

.modalWindow

{
background-color: #FFF;
border: solid3px #333;
padding:3px;
position: absolute;
left: 50%;
top: 50%;
}
 
I'm not sure if you need the position: absolute; or not though.
 

I've added the underlined lines into my css document and it didn't have an effect on my modal popup. It's still not graying the background, i know these styles work as i've made other ASP.net sites with them, but DotNetNuke doesn't seem to be happy with AJAX.

I'm still trying to work this issue out, i'll post a solution if i come across one, but help is still appretiated.

Thanks to all that replied

SyntaxC4

Modal Popup OnClick (Server Side) Issues

I'm utilizing a modal popup to allow a user to enter a new record for a gridview on the screen. Once the modal popup is displayed (via clicking a link button), the user enters some values in some textboxes and the user clicks the save button. At this point the application executes the code in the code-behind for the button. However, if this is the first viewing of the screen (i.e. I just pressed play in visual studio), the values of the textboxes contained within the panel contain blank values (even though the user entered values).

The second strange thing that occurs, is if this is not the first viewing of this page and I click the link to display the modal popup, enter the text and click save, the OnClick (server side) fires twice.

Has anyone run across this issue? If so, how did you resolve it?

Thanks in advance,

Brian

Please try your scenario with the recently available61106 release of the Toolkit (and ASP.NET AJAX Beta 2). If the problem persists, then please reply with acomplete, self-contained sample page that demonstrates the problem so that we can investigate the specific behavior you're seeing. Thank you!

If you are using the Official Beta 2 release - don't use it (As David recommended) - unless they updated the bits on the day they posted it as Beta 2 Release -its broke...- go to the source tab and download today's release...about 1/3 of the controls with the 'official Beta 2 ' release would exhibit that behavior (the accordian - would never accept user clicks, drag panel never dragged, always visible just remained visible in one spot, and the modal exhibited your issues... had something to do with types function or something...If you are using Beta 1 or Atlas - it will be more about how you are wrapping the modal - you should place it in its own update panel even if you are attaching it into every row. I personally have the modal as a single instance and I control the modal show and hide in codebehind... examples are in my blog entries...

modal popup problem. blank textboxes

hi, im having problems here. i have a modal popup that when user clicks the edit button, the modal popup will appear and it contains the textboxes for editing.what's od is that the textboxes are all blank and i when i checked my codes not using modal popup, it is doing fine. i have these codes below:

1<asp:Button ID="btnEditPer" runat="server" Text="OK" />2 <asp:Button ID="btnCancel" runat="server" Text="Cancel" />3 </asp:Panel>45 <cc1:ModalPopupExtender ID="mpEditPer" runat="server"6 TargetControlID="lbEditPer"7 PopupControlID="Panel1"8 BackgroundCssClass="modalBackground"9 DropShadow="true"10 CancelControlID="btnCancel" >11 </cc1:ModalPopupExtender>

and then in the code behind:

1if (!IsPostBack)2 {3string id = Request.QueryString["EmployeeID"];4 Employee emp = Employee.ShowEmployeeByID(id);56this.lblFirstName.Text = emp.FirstName;7this.lblMiddleName.Text = emp.MiddleName;8this.lblLastName.Text = emp.LastName;9this.lblBirthdate.Text = emp.BirthDate.ToString();10this.lblBirthplace.Text = emp.BirthPlace;11this.lblNationality.Text = emp.Nationality;12this.lblReligion.Text = emp.ReligionID;13this.lblGender.Text = emp.Gender;14this.lblCivilStatus.Text = emp.CivilStatus;15this.lblHeight.Text = emp.Height;16this.lblWeight.Text = emp.Weight;17this.lblHairColor.Text = emp.HairColor;18this.lblEyeColor.Text = emp.EyeColor;1920//load data in textboxes and lists21this.txtFirstName.Text = emp.FirstName;22//other codes goes here23 }
i just wanted to test if i can get the value of the first name, but no luck. hope u can help me on this one. thanks in advance.

Is this code in the server click handler of the modalpopup targetcontrol button? The click event on that is cancelled and the modal popup only shows the popup on the client side. Could you possibly provide some more details on the setup?

Saturday, March 24, 2012

Modal pop-up questions

First, I'd like to display a modal pop-up programatically instead of it being triggered by a button click event or similar.

Secondly, if the user clicks OK, I'd like it to trigger a server-side function.

I've tried several approaches to doing these and have not had much success. Could anyone provide some direction?

Thanks

To show and hide the modal popup programatically:

ModalPopupExtender1.Show() and ModalPopupExtender1.Hide() ' Change "ModalPopupExtender1" to whatever yours is called.

To get your "Okay" button to fire normal server-side code, just don't specify an OkControlID for the ModalPopupExtender. Handle the button's click event normally and just use the above .Hide() method to close the popup.

Modal PopUp with Custom User Control

I'm using the September preview to create a modal pop up. But the twist here is that I would like the popup toload in a custom page.
In my case, the sample file, TrackingNumber.ascx, is to be displayed when the modal popup is displayed.

It mostly works. If the OK or Exit buttons are clicked, the popup closes normally.
When the Save button is clicked,however, information is written to the database, and the label shows the time when the button was clicked,butnow the OK and Exit buttons stop working.

Any suggestions as what I am doing wrong? Is there a better way to encapsulate user controls in a modal pop up?
Thanks!

default2.aspx:

<%@dotnet.itags.org. Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" %>

<%@dotnet.itags.org. Register src="http://pics.10026.com/?src=TrackingNumber.ascx" TagName="TrackingNumber" TagPrefix="uc1" %>

<%@dotnet.itags.org. Register Assembly="AtlasControlToolkit" Namespace="AtlasControlToolkit" TagPrefix="AtlasToolkit" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head id="Head1" runat="server">

<title>Test Modal PopUps With Custom User Controls</title>

<link href="http://links.10026.com/?link=ModalPopUp.css" rel="stylesheet" type="text/css" />

<atlas:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="True" />

</head>

<body>

<form id="form1" runat="server">

<div>

<AtlasToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" >

<AtlasToolkit:ModalPopupProperties

TargetControlID="LinkButton1"

PopupControlID="UpdatePanel1"

BackgroundCssClass="modalBackground"

DropShadow="True"

OkControlID="TrackingNumber1$OkButton"

CancelControlID="TrackingNumber1$CancelButton"

/>

</AtlasToolkit:ModalPopupExtender>

<asp:LinkButton ID="LinkButton1" runat="server" Style='z-index: 102; left: 304px;

position: absolute; top: 14px">LinkButton</asp:LinkButton>

<atlas:UpdatePanel ID="UpdatePanel1" runat="server" >

<ContentTemplate>

<uc1:TrackingNumber ID="TrackingNumber1" runat="server" />

</ContentTemplate>

<Triggers>

<atlas:ControlEventTrigger ControlID="TrackingNumber1$btnSave" EventName="Click" />

</Triggers>

</atlas:UpdatePanel>

</div>

</form>

<script type="text/xml-script">

<page xmlns:script="http://schemas.microsoft.com/xml-script/2005">

<references>

</references>

<components>

</components>

</page>

</script>

</body>
</html>

TrackingNumber.ascx:
<%@dotnet.itags.org. Control Language="VB" AutoEventWireup="true" CodeFile="TrackingNumber.ascx.vb" Inherits="TrackingNumber" EnableViewState="true" %>

<asp:Panel ID="PanelTrackingNumber" runat="server" BackColor="#DAE8F4" Font-Bold="True" Height="173px"

Style='z-index: 104; position: relative;" Width="285px" >

<asp:TextBox ID="txtTrackingNumber" runat="server" Style='z-index: 100; left: 40px;

position: absolute; top: 83px"></asp:TextBox>

<asp:Label ID="Label1" runat="server" Font-Bold="False" Style='z-index: 101; left: 28px;

position: absolute; top: 53px" Text="What is the tracking Number?"></asp:Label>

Tracking number of tracking cover sheet for records.

<asp:Label ID="Label10" runat="server" ForeColor="Red" Height="10px" Style='z-index: 102;

left: 212px; position: absolute; top: 55px" Text="*" Width="13px"></asp:Label>

<asp:Label ID="Label13" runat="server" ForeColor="Red" Style='z-index: 103; left: 8px;

position: absolute; top: 149px" Text="* Optional"></asp:Label>

<asp:Button ID="OkButton" runat="server" Style='z-index: 104; left: 10px; position: absolute;

top: 115px" Text="OK" />

<asp:Button ID="CancelButton" runat="server" Style='z-index: 105; left: 98px; position: absolute;

top: 145px" Text="Exit" />

<asp:Button ID="btnSave" runat="server" Style='z-index: 106; left: 59px; position: absolute;

top: 111px" Text="Save" />

<asp:Label ID="lblNow" runat="server" Style='z-index: 108; left: 112px; position: absolute;

top: 111px" Text="Label" Width="119px"></asp:Label>

</asp:Panel>

TrackingNumber.ascx.vb:

Imports System.Data.SqlClient

Partial Class TrackingNumber

Inherits System.Web.UI.UserControl

Protected Sub WriteToDB()

Dim oCon As SqlConnection

Dim oComm As SqlCommand

oCon = New SqlConnection("server=MODREP1;database=SAP_DB;uid=UserId;pwd=xxxx;")

oCon.Open()

oComm = New SqlCommand("UPDATE Records SET Data='" & Now.ToLongTimeString & "' WHERE ID=4", oCon)

oComm.ExecuteNonQuery()

oComm.Dispose()

oCon.Dispose()

End Sub

Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click

WriteToDB()

Me.lblNow.Text = Now.ToLongTimeString

End Sub

End Class

ModalPopUp.css:
/*Modal Popup*/

.modalBackground {

background-color:Gray;

filter:alpha(opacity=70);

opacity:0.7;

}

.modalPopup {

background-color:#ffffdd;

border-width:3px;

border-style:solid;

border-color:Gray;

padding:3px;

width:250px;

}

I tried placing the ModalPopupExtender tag inside the UpdatePanel. I've tried placing the ModalPopupExtender in the .ascx file, and with & with out the Panel elements. In the lastest configuration, clicking the OK and Exit buttons causes the popup to close normally. But when the Save button is clicked to perform server side processing, the following happens:

data is written to the database (desired effect)


The error is probably because the postback within the UpdatePanel stomps the relevant DOM elements and then the event handlers ModalPopup set up are gone. You might try sticking the ModalPopupExtender tag inside the UpdatePanel, too, as this often helps.
One other thing people sometimes have success with is wrapping the Save button in an UpdatePanel.

I don't know if you have fixed this issue, or if you even look again, but in your server-side code you can call ModalPopupExtender1.Show();

which will display the modal dialog box after the post back.

ModalDialog Switch Panel content on click

I was wondering if there was a way to change the inner content of the modal panel when the user clicks a certain button. Is this a job for the UpdatePanel?

As it stands, I'm just binding to a TargetControlID, and I can Ok/Cancel, but would like the content to change onOk.

I'm quite new to this whole atlas way of thinking, so I'm not sure how to co-mingle all this client/server stuff.

Any help would be appreciated.

-Ty

Hi,

you can also use the DynamicPopulateExtender to load new content inside a panel.

Regards
Marc André

Wednesday, March 21, 2012

ModalPanel - How can I us AJAX instead of postback to update database ?

I'm new to AJAX and this suite of tools. I have a page that when a user clicks a link button my ModalPanel with various input fields appears. When the user clicks the okay button I want to make an async call instead of having the page post back. I need to be able to call one of my business objects defined in C# so what is the best way to do this?

If you can provide details or even a small example I would appreciate it.

My code behind method looks like this:

void OnClick(...)

{

Broker b = new Broker();

b.name = NameTextBox.Text;

b.account = AccountTextBox.Text;

b.Save();


}

Why not just wrap the modalpopup in an updatepanel and let the page postback? It is easier then to have access to the server controls from the form and have full interaction with the other page elements during the postback in case you want to update other stuff on the page.

What benefits are you looking for by not posting back?

Jason

ModalPopup - Logic to databind control outside of modal

Hello All,

I am have a modal popup that appears and takes some input from a user. The user can then hit "submit" and logic behind the onclick for the submit button validates the input, and, if valid, submits that input to a database to be inserted.

this works great. I have update panels inside of the modal doing the work, and the user can submit as many entries as the want without the modal closing.

However, in the same method, after I update the database, I call another method to get new data from the database, and to re-databind the control they were looking at before the modal opened.

But the control (a listbox) does not change. It is not being databound. I even tried clearing the items from the listbox, and the items still remain.

I am not sure why the listbox is not updating from the logic. I would assume its not becuase the control is not in the same update panel, or the control is not in the modal popup. The listbox control is in its own update panel.

So I am trying to figure out how to make a control that is in another update panel, not in the modal popup update with logic triggered in the modal popup. I've thought about using the "onOKScript" in the modal popup properties to use some sort of JS to re-databind the control, but I am not sure how to do this.

Any ideas would be extreamly helpful

Thanks

-Shane

Hi Shane,

What you're describing should work. Code in an event handler invoked via oneUpdatePanel should be able to update controls in anotherUpdatePanel. Perhaps you can post a simple demo showing what's not working for you and we can take a look.

Thanks,
Ted

modalpopup & user control question

Hi all,

I hope all of you are doing well!Big Smile I have an interesting situation that I wanted to get some input on.

I have a ascx usercontrol that contains about a dozen textbox and dropdown controls inside an updatepanel. It also has a few buttons that fire server side events, all contained and handled in the code behind page for the usercontrol. This usercontrol resides on a host aspx page inside another updatepanel control. Everything works fine thus far.

Now, what I would like to do is dynamically popup the usercontrol inside a modalpopup when the user clicks on a button on the host aspx page. The user would then enter the data for the dozen or so fields on the popped up usercontrol, hit update, which would invoke the server side code inside the code behind of the usercontrol and finally close the modalpopup.

Is this possible? Some insight on how I can do this would be great. Some links to code samples would be even more awesome.

Thanks so much!

Hi,

Here is a sample made according to your requirements:

1. UserControl

<%@. Control Language="C#" ClassName="WebUserControl" %><script runat="server"> protected void Button1_Click(object sender, EventArgs e) { Label1.Text = DateTime.Now.ToString(); success = true; } // this variable is used to determine if the modal popup should close public bool success = false;</script><asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /> <br /> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> </ContentTemplate></asp:UpdatePanel> 

2. Page

<%@. Page Language="C#" %><%@. Register src="http://pics.10026.com/?src=WebUserControl.ascx" TagName="WebUserControl" TagPrefix="uc1" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> protected void Page_Load(object sender, EventArgs e) { this.PreRender += new EventHandler(default_aspx_PreRender); } void default_aspx_PreRender(object sender, EventArgs e) { if (WebUserControl1.success) UpdatePanel1.Update(); }</script><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> </div> <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> <ContentTemplate>    <asp:Panel ID="Panel1" runat="server" Height="50px" Width="125px"> <uc1:WebUserControl ID="WebUserControl1" runat="server" /> </asp:Panel> <asp:Button ID="Button1" runat="server" Text="Show" /> <ajaxToolkit:ModalPopupExtender PopupControlID="Panel1" ID="ModalPopupExtender1" runat="server" TargetControlID="Button1"> </ajaxToolkit:ModalPopupExtender> </ContentTemplate> </asp:UpdatePanel>   </form></body></html>

Hope this helps.


Thanks. This worked perfectly!!

ModalPopup add rows to datagrid

I am trying to have a ModalPopupExtender when a button is clicked on the main page. On the popup, a user can enter a couple of peices of information and click the add button. I have that part working, but I am trying to make it more dynamic. Does anyone know how to make it so:

1) The popup doesn't disppear after clicking the add button, so the user can add more than one row without having to click the button on the main page

2) The datagrid is updated withwout postback

I have tried using the UpdatePanel, but I keep geeting an error message: An extender can't be in a different UpdatePanel than the control it extends.

Here is my code from the page:

<asp:ScriptManagerID="ScriptManager1"runat="server">

</asp:ScriptManager>

<table><tr><td><asp:ButtonID="ButtonAddItem"runat="server"Text="Button"/></td></tr>

<tr><td>

<asp:DataGridID="DataGridTemplate"runat="server"AutoGenerateColumns=falseDataKeyField="ItemID"BorderStyle=NoneBorderWidth=0>

<Columns>

<asp:BoundColumnDataField="ItemDescr"></asp:BoundColumn>

<asp:BoundColumnDataField="TimeFrame"></asp:BoundColumn>

</Columns>

</asp:DataGrid>

</td></tr></table>

<asp:PanelID="PanelAddTemplateItem"runat="server"style="display:none;"CssClass="modalPopup">

<table>

<tr><tdcolspan=2>Add Line Item</td></tr>

<tr><td>Line Item:</td><td><asp:TextBoxID="TextBoxAddTemplate"runat="server"TextMode=MultiLine></asp:TextBox></td></tr>

<tr><td>Time Frame:</td><td><asp:TextBoxID="TextBoxAddTemplateTime"runat="server"></asp:TextBox></td></tr>

<tr><tdcolspan=2><asp:LabelID="LabelAddTemplate"runat="server"></asp:Label></td></tr>

<tr><td><asp:ButtonID="ButtonAddTemplate"runat="server"Text="Add"/></td><td><asp:ButtonID="ButtonAddTemplateOK"runat=serverText="finished"/></td></tr>

</table>

</asp:Panel>

<ajaxToolkit:ModalPopupExtenderID="ModalPopupExtenderAddTemplateLine"runat="server"TargetControlID="ButtonAddItem"PopupControlID="PanelAddTemplateItem"CancelControlID="ButtonAddTemplateOK"BackgroundCssClass="modalBackground"DropShadow=true>

</ajaxToolkit:ModalPopupExtender>

I was able to figure out my first problem by putting the updatepanel inside the asp:panel that the modalpopupextender displays. However, I still cannot seem to figure out how to update the datagrid. Is it possible to update the grid on-screen without a postback? Thanks!


Hi Briancostea,

I think you should add another UpdatePanel to your page and remove the DataGrid into the newly added UpdatePanel.So now there are two UpdatePanels. When we add new records, one UpdatePanel will be postback and add data to Database or somewhere else and next the another UpdatePanel will be refreshed. To refresh the UpdatePanel's content , please use add these code to your page.

 <script type="text/javascript" language="javascript"> var eventButton; Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler); Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler); function BeginRequestHandler(sender, args){ eventButton=args.get_postBackElement().id } function EndRequestHandler(sender, args){ if(eventButton =="Button1" ){ //refresh UpdatePanel2 by using __doPostBack() state. } } </script>

I hope this help.

Best regards,

Jonathan