Showing posts with label pop. Show all posts
Showing posts with label pop. Show all posts

Wednesday, March 28, 2012

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.

Saturday, March 24, 2012

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.

modal window (asp.net ajax page) not closing

Hello, I'm creating a pop up using 'window.showModalDialog', the page that opens is a asp.net ajax page. I'm displaying a gridview on this. When user selects a row from the gridview, i need to store the selected value to session variable and close the popup window. I'm using the below code on the select image button click. If i manually closes the popup window, it get backs to the parent. The code on click event is

ProtectedSub OnSelect(ByVal senderAsObject,ByVal eAs CommandEventArgs)

Dim strScriptAsString ="<script language='javascript'>window.returnValue='" + retVal +"';window.close();</script>"

If (e.CommandName.Equals("cmdSelTag"))Then

Session(Utility.Constants.SelectedTagDefinitionId) = e.CommandArgument.ToString()

IfNot ClientScript.IsStartupScriptRegistered("clientScript")Then

ClientScript.RegisterStartupScript(GetType(Page),"clientScript", strScript)

EndIf

EndIf

EndSub

Note: If make it asp.net page rather than asp.net ajax page, then this works fine.

Any help is appreciated.

Hi.. i used ScritManager.RegisterStartupScript instead of ClientScript.RegisterStartupScript. Now its working.

Wednesday, March 21, 2012

ModalPopUp - Getting value from DropDownList

I have a dropdownlist in my modal pop up and when I click the submit button the page posts back but DropDownList.SelectedValue is empty. I need that value so that I can submit to the database when the btnSubmit_Click method is fired.

My modal extender:

<atlasToolkit:ModalPopupExtenderID="ModalPopupExtender_AddEntity"runat="server"><atlasToolkit:ModalPopupPropertiesTargetControlID="imgBtn_AddEntity"DropShadow="true"PopupControlID="pnlAddEntityModal"CancelControlID="btnCancelEntity"BackgroundCssClass="modalBackground"OkControlID="btnAddEntity"/></atlasToolkit:ModalPopupExtender>

My Submit button:

<

asp:Buttonid="btnAddEntity"Width="110"runat="server"Text="Submit"CssClass="button"OnClick="btnSubmit_Click"UseSubmitBehavior="false"/>Might you be hitting the issue outlined in the following post:http://forums.asp.net/thread/1316941.aspx?

Actually I was able to solve the problem using this bit of Javascript and C#. BUT, it seems that the selected value of the dropdownlist is not always there. It seems a littl buggy. Can someone look at my code and let me know if I am missing something:

<scripttype="text/javascript">var selectedEntity;var selectedProperty;//var selectedValues;function onOk() {

selectedEntity = document.getElementById(

'ddlEntity').value +"-" + document.getElementById('ddlProperty').value;//selectedProperty = document.getElementById('ddlProperty').value;//selectedValues = selectedEntity + "-" + selectedProperty;

__doPostBack(

'btnAddEntity',selectedEntity);

}

</script>

<atlasToolkit:CascadingDropDownID="CascadingDropDown1"runat="server"><atlasToolkit:CascadingDropDownPropertiesTargetControlID="ddlEntity"Category="Entity"PromptText="<-- Selected an Entity -->"ServicePath="webservices/ws_Timetracking.asmx"ServiceMethod="GetEntites"/><atlasToolkit:CascadingDropDownPropertiesTargetControlID="ddlProperty"ParentControlID="ddlEntity"PromptText="<-- Select a Property -->"ServiceMethod="GetPropsForEntity"ServicePath="webservices/ws_Timetracking.asmx"Category="Property"/></atlasToolkit:CascadingDropDown>

<atlasToolkit:ModalPopupExtenderID="ModalPopupExtender_AddEntity"runat="server"><atlasToolkit:ModalPopupPropertiesTargetControlID="imgBtn_AddEntity"DropShadow="true"PopupControlID="pnlAddEntityModal"CancelControlID="btnCancelEntity"BackgroundCssClass="modalBackground"OkControlID="btnAddEntity"OnOkScript="onOk()"/></atlasToolkit:ModalPopupExtender>

Sorry, I'm not seeing the empty SelectedValue issue on my end with the recent 60626 release. If you still see it with that release, could you please post a small, simple example of the problem so we can look into it further? Thanks!


You're talking about the AtlasControlKit release, right? I have 1.0.60504.0. Do I just download the lastest version and Add Reference to the AtlasControlKit.dll into my project?

Yes, the AtlasControlToolkit release 60626 which can be downloaded from here:http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=AtlasControlToolkit&ReleaseId=70

You download it and extract the files and you'll see an environment very much like the 60504 release, except with additional controls, some fixes, automated testing, etc.. You should be able to substitute the new 60626 versions of AtlasControlToolkit.dll and Microsoft.AtlasControlExtender.dll for the old 60504 versions without any problems. Just remove the references to the old DLLs and add references to the new ones and you should be set!

ModalPopUp and Frame

Hi all,

My page has 2 frames. The modal pop up is in the left frame. When I use the show() method to show the modal popup, it showed in the center of the left frame.

Is there a way to show the modal pop up in the middle of the page instead of center of the frame?

Thanks,

Testz.

I believe I cover some of the relevant issues here:http://forums.asp.net/ShowPost.aspx?PostID=1357977.

I'm having the same issue -- were you able to follow the link?