Showing posts with label below. Show all posts
Showing posts with label below. Show all posts

Monday, March 26, 2012

Modal popup is not modal

Hi!

My modal popup doesnt seem to be modal: see the code below. Everything works fine, but when popup appears link behind still can be clicked... What's missing?

<%@dotnet.itags.org. Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><%@dotnet.itags.org. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="AjaxToolkit" %><!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 runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <div> <asp:Button ID="btnShowPopup" Text="ShowPopup" runat="server" /> <a href="http://www.google.com">Some link</a> <br /> <div id="divPopup" runat="server" style="background-color:Silver; width:500px; height:300px;"> <div id="divHeader" runat="server" style="background-color:Lime"> Header </div> <br /> Some popup content <br /> <asp:Button runat="server" ID="btnOK" Text="OK" /> </div> </div> <AjaxToolkit:ModalPopupExtender runat="server" ID="extPopup" TargetControlID="btnShowPopup" PopupControlID="divPopup" OkControlID="btnOK" PopupDragHandleControlID="divHeader" /> </form></body></html>

PawelRoman:

My modal popup doesnt seem to be modal: see the code below. Everything works fine, but when popup appears link behind still can be clicked... What's missing?

So your issue isn't with anything pertaining to the ModalPopupExtender, but rather with your CSS. Basically, you don't have any CSS. You need to set theBackgroundCssClass attribute on the ModalPopupExtender. Then, you'll need to add that CssClass using inline CSS or using a stylesheet. The CssClass must contain a background definition (background-color or background-image).

Modal Popup Problem

Plz check My below code

<%@dotnet.itags.org.PageLanguage="VB"AutoEventWireup="false"CodeFile="ModalPopUp_In_Datagrid.aspx.vb"Inherits="ModalPopUp_In_Datagrid" %>

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

<scripttype="text/javascript"language="javascript">

function shopModalPopup(employeeID){

//show the ModalPopupExtender

$get("<%=Label1.ClientID %>").value = employeeID;returnfalse;

}

</script>

<styletype="text/css">

.modalBackground

{

background-color:#000;

-moz-opacity:0.7;

opacity:.70;filter:alpha(opacity=70);

}

</style>

</head>

<body>

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

<div>

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

</asp:ScriptManager>

</div>

<asp:PanelID="Panel1"runat="server"Height="50px"Width="125px">

<asp:GridViewID="GV1"runat="server"AutoGenerateColumns="False"DataKeyNames="RID">

<Columns>

<asp:BoundFieldDataField="rid"HeaderText="rid"/>

<asp:BoundFieldDataField="name"HeaderText="Name"/>

<asp:BoundFieldDataField="off_phone"HeaderText="OFF_PHONE"/>

<asp:BoundFieldDataField="photo"HeaderText="Photo"/>

<asp:TemplateField>

<ItemTemplate>

<asp:LinkButtonrunat="server"Text="Popup"CommandName="EditRow"CausesValidation="false"ID="lnkPopup"OnCommand="lnkPopup_Command"></asp:LinkButton>

</ItemTemplate>

</asp:TemplateField>

</Columns>

</asp:GridView>

</asp:Panel>

<asp:Panelrunat="Server"ID="panel2">

<asp:LabelID="Label2"runat="server"Text="Label"Visible="False"></asp:Label>

<cc1:ModalPopupExtenderID="ModalPopupExtender2"runat="server"PopupControlID="popupPanel"

BackgroundCssClass="modalBackground"TargetControlID="Label2">

</cc1:ModalPopupExtender>

</asp:Panel>

<asp:PanelID="popupPanel"runat="server"Height="50px"Width="125px">

Click To Display Authors Name:

<asp:LabelID="Label1"runat="server"></asp:Label>

<asp:ButtonID="btnShowAuthorName"runat="server"

Text="Show Author's Name"></asp:Button><br/>

<asp:LabelID="lblAuthorsName"runat="server"BackColor="Beige"ForeColor="Red"></asp:Label>

<br/>

<br/>

<asp:ButtonID="btnOk"runat="server"Text="OK"/>

<asp:ButtonID="btnCancel"runat="server"Text="Cancel"/>

</asp:Panel>

<br/>

</form>

</body>

</html>

Server Side:

Sub fill_values()

Label1.Text ="a"

EndSub

ProtectedSub GV1_RowCommand(ByVal senderAsObject,ByVal eAs System.Web.UI.WebControls.GridViewCommandEventArgs)Handles GV1.RowCommand

If e.CommandName ="EditRow"Then

fill_values()

ModalPopupExtender2.Show()

EndIf

EndSub

---------------------------------------

Now when i click link button in datagrid...then server side code is executed namedfill_values() and then to show Modal Popup showing those values...

But now values are being filled but Modal Popu doesn't come...

Plz help......

Hi Varun,

Please don't attach a hidden Control(visible= false) to your ModalPopupExtender or it won't work because no Dom element generate to the client. Also don't put $get function before ScriptManager. Here is the sample , please pay attention to the "Bold" part.

<%@. Page Language="VB" %><%@. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> Sub fill_values() Label1.Text = "a" End Sub Protected Sub GV1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) If e.CommandName = "EditRow" Then fill_values() ModalPopupExtender2.Show() End If End Sub</script><html xmlns="http://www.w3.org/1999/xhtml"><head id="Head1" runat="server"> <title>Untitled Page</title> <style type="text/css"> .modalBackground { background-color:Gray; filter:alpha(opacity=70); opacity:0.7; } .modalPopup { background-color:#FFD9D5; border-width:3px; border-style:solid; border-color:Gray; padding:3px; width:250px; } </style></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:Panel ID="Panel1" runat="server" Height="50px" Width="125px"> <asp:GridView ID="GV1" runat="server" AutoGenerateColumns="False" DataKeyNames="EmployeeID" DataSourceID="SqlDataSource1" AllowPaging="True" onrowcommand="GV1_RowCommand" > <Columns> <asp:BoundField DataField="EmployeeID" HeaderText="EmployeeID" /> <asp:BoundField DataField="LastName" HeaderText="LastName" /> <asp:BoundField DataField="FirstName" HeaderText="FirstName" /> <asp:BoundField DataField="Title" HeaderText="Title" /> <asp:TemplateField> <ItemTemplate> <asp:LinkButton runat="server" Text="Popup" CommandName="EditRow" CausesValidation="false" ID="lnkPopup"></asp:LinkButton> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NORTHWNDConnectionString%>" SelectCommand="SELECT [EmployeeID], [LastName], [FirstName], [Title] FROM [Employees]"></asp:SqlDataSource> </asp:Panel> <asp:Panel ID="popupPanel" runat="server" CssClass="modalPopup" Height="200px" Width="200px" style="display:none"> Click To Display Authors Name: <asp:Label ID="Label1" runat="server"></asp:Label> <asp:Button ID="btnShowAuthorName" runat="server" Text="Show Author's Name" OnClientClick="getName(); return false;"></asp:Button><br /> <asp:Label ID="lblAuthorsName" runat="server" BackColor="Beige" ForeColor="Red"></asp:Label> <br /> <br /> <asp:Button ID="btnOk" runat="server" Text="OK" /> <asp:Button ID="btnCancel" runat="server" Text="Cancel" /> </asp:Panel><cc1:ModalPopupExtender ID="ModalPopupExtender2" runat="server" PopupControlID="popupPanel" BackgroundCssClass="modalBackground" TargetControlID="Label2" CancelControlID="btnCancel" OkControlID="btnOk"> </cc1:ModalPopupExtender> <div style="display:none"> <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label></div> <script type="text/javascript" language="javascript">function getName(){ var labelValue = $get("<%=Label1.ClientID%>").innerHTML; } </script> </form></body></html>

I hope this hlep.

Best regards,

Jonathan

Wednesday, March 21, 2012

modalpopup - screen in back isnt being disabled

Can someone tell me what is wrong with my code below. when modalpop screen comes up, the screen in the back isn't being disabled. Plz help

<asp:Table ID="TableAdd" runat="server" Width="568px">
<asp:TableRow ID="TableRow90" runat="server">
<asp:TableCell ID="TableCell96" Width="50px" runat="server"></asp:TableCell>
<asp:TableCell ID="TableCel97" Width="120px" runat="server"></asp:TableCell>
<asp:TableCell ID="TableCell98" Width="50px" runat="server"></asp:TableCell>
<asp:TableCell ID="TableCel200" Width="120px" runat="server"></asp:TableCell>
<asp:TableCell ID="TableCell91" Width="50px" runat="server"></asp:TableCell>
<asp:TableCell ID="TableCell93" Width="120px" runat="server"><asp:Button ID="Insertbutton" runat="server" Text="Insert Additional Detail Type" /></asp:TableCell>
<asp:TableCell ID="TableCell92" Width="50px" runat="server"></asp:TableCell>
</asp:TableRow>
</asp:Table>


<!--Modal Screen to Insert Allocation Detail records !-->

<asp:Panel ID="Panel1" runat="server" Style="display: none" BackColor=white>

<asp:UpdatePanel ID="UpdatePanel3" runat="server" UpdateMode="Conditional" >
<ContentTemplate>
<asp:DetailsView ID="DetailsView2" runat="server"
AutoGenerateRows="False"
datakeynames="tran_id,tran_fk"
DataSourceID="Allocation"
DefaultMode="Insert"
HeaderText="Add a New Detail Allocation Info" Font-Bold="True">
<Fields>


<asp:TemplateField HeaderText="Type:">
<ItemTemplate>
<asp:DropDownList id="AddType" DataSourceID="TypeSource" Runat="Server"
DataTextField="tran_desc" DataValueField="tran_pk" SelectedValue='<%# Bind("tran_pk") %>'/>
</ItemTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="Amount:">
<ItemTemplate>
<asp:Label ID="amount" Text='<%# Eval("amount") %>' Runat="Server" />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="amount" runat="server" Text='<%# Bind("amount") %>' ></asp:TextBox>
<ajaxToolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender1" runat="server"
TargetControlID="amount" FilterType="Custom, Numbers" ValidChars="." />
</EditItemTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="Date:" ItemStyle-Width=125 >
<ItemTemplate>
<asp:Label ID="trandate" Text='<%# Eval("trandate") %>' Runat="Server" />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="trandate" runat="server" Text='<%# Bind("trandate") %>' Width=75></asp:TextBox>
<asp:ImageButton ID="ImgBntCalc" runat="server" ImageUrl="~/images/Calendar_scheduleHS.png" CausesValidation="False" />
<ajaxToolkit:MaskedEditExtender ID="MaskedEditExtender5" runat="server"
TargetControlID="trandate"
Mask="99/99/9999"
MessageValidatorTip="true"
CultureName="en-US"
OnFocusCssClass="MaskedEditFocus"
OnInvalidCssClass="MaskedEditError"
MaskType="Date"
DisplayMoney="Left"
AcceptNegative="Left"
ErrorTooltipEnabled="True" />
<ajaxToolkit:CalendarExtender ID="CalendarExtender1" runat="server" Format="MM/dd/yyyy" TargetControlID="trandate" PopupButtonID="ImgBntCalc" />
</EditItemTemplate>
</asp:TemplateField>

<asp:TemplateField>
<EditItemTemplate>
<asp:Button ID="BtnInsert" CommandName="Insert" Text="Insert" Runat="Server"/>
</EditItemTemplate>
</asp:TemplateField>
</Fields>
<HeaderStyle Font-Bold="True" BackColor="Silver" HorizontalAlign="Center" />
</asp:DetailsView>
</ContentTemplate>

</asp:UpdatePanel>

<p style="text-align: center;">
<asp:Button ID="OkButton" runat="server" Text="Close" />
</p>

</asp:Panel>
<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender" runat="server"
TargetControlID="Insertbutton"
PopupControlID="Panel1"
BackgroundCssClass="modalBackground"
OkControlID="OkButton"
DropShadow="true">
</ajaxToolkit:ModalPopupExtender>

this doesnt happen automatically...you need to manually disable the other stuff.


Are you able to point me in the right direction on how to do that? I'm looking at the sampleWebsite and the video and I have no idea, besides in the style, on where they gray out the background page


just as you said... in styles.

What I've done is wrap it all in a container that I set to Enabled=False when they click the button/link/etc that causes the Popup


I have anexample of making a modal UpdateProgress. You should be able to use similar styles for the BackgroundCssClass as I do in the#progressBackgroundFilterexample

For example:

.modalBackground{
background-color:#000;
filter:alpha(opacity=50);
opacity:0.5;
}

-Damien


thank you guys for your help. I'm allset