Showing posts with label aspx. Show all posts
Showing posts with label aspx. Show all posts

Wednesday, March 28, 2012

Modal Popup Extender - Setting Focus

Hi,

I have HostModalPopup.aspx webform with a ShowModalWindow button (When clicked shows a Modal Popup Window) and there are some text boxes after the button.

The Modal Pop Up window has 3 controls: a text box field, a submit button and a close button.

1) When the Modal Popup window is shown, I would like to be able to setfocus to the textbox. I thought I should be able to do this with document.getElementById('TextBox1').focus() on some event that gets triggered when the modal popup window is made visible, but I could not find any such DHTML event.

2) The taborder/tabindex of the controls in HostModalPopup.aspx, once the ShowModalWindow is opened and closed, no longer works. If I set the focus to one of the textboxes and hit tab the cursor goes to address bar instead of going to a textbox with next tabindex. I am using AJAX Control Kit verion 1.0.10606.0

Any help is greatly appreciated.

- Surya

Use ScriptManager1.SetFocus(TextBox1)


http://www.asp.net/AJAX/Documentation/Live/mref/O_T_System_Web_UI_ScriptManager_SetFocus.aspx

http://msdn2.microsoft.com/en-us/e04ah0f4


Thank you guys!

The ScriptManager.SetFocus did it for the first issue.

-Surya

Modal Popup Extender and OkControID

Hello misters,

I have a page ASPX with ModalPopupExtender control, with the following properties:

TargetControlID="btnAnyadirObs"
PopupControlID="Panel1"


OkControlID="btnAnyadirObsAceptar"
CancelControlID="btnAnyadirObsCancel"
OnOkScript="onYes()"
OnCancelScript="onCancel()"

I have a Panel (Panel1) with two buttons: btnAnyadirObsAceptar and btnAnyadirObsCancel.

The buttons have Click event (code-behind .cs).

My trouble is that it is not execute Click event for button btnAnyadirObsAceptar (the OkControlID). I want to press the button OK in modal popup extender and I call Click event (server event of code-behind, file .cs).

Only execute onYes function javascript but it fails because typeof(Sys.WebForms.PostBackAction) == "undefined"

For javascript function onCancel() , $("Label1") fails.

See all code below, please.


The code begins here:

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

... more code...

<cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server"

TargetControlID="btnAnyadirObs"
PopupControlID="Panel1"
OkControlID="btnAnyadirObsAceptar"
CancelControlID="btnAnyadirObsCancel"
OnOkScript="onYes()"
OnCancelScript="onCancel()"

DropShadow="true" PopupDragHandleControlID="Panel3">
</cc1:ModalPopupExtender>

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

<asp:Panel ID="Panel3" runat="server"><div>TITLE</div></asp:Panel>


<filtros:EmbeddedUserControlLoader ID="UCObservacionesPopup" runat="server" AssemblyName="TareaRetenida.UC"
ControlClassName="UCRetenidaCentrolControlObservacionesPopup" ControlNamespace="TareaRetenida.UC" />


<controles:Boton ID="btnAnyadirObsAceptar" runat="server" CausesValidation="false" Text="Resx OK" OnClick="btnAnyadirObsAceptar_Click" />

<controles:Boton ID="btnAnyadirObsCancel" runat="server" CausesValidation="false" Text="Resx Cancel" OnClick="btnAnyadirObsCancel_Click" />


</asp:Panel>

The javascript functions:

function onYes()

{

var idBoton= "MY CLIENTID OF BUTTON OK";
if (typeof(Sys.WebForms.PostBackAction) != "undefined")
{
var postBack = new Sys.WebForms.PostBackAction();
postBack.set_target(idBoton);
postBack.set_eventArgument('');
postBack.performAction();
}

}

function onCancel()
{
//no postback necessary
try
{
$('Label1').innerText = 'Action canceled';
}
catch(err)
{
alert('onCancel' + "Error " + err.description);
}
}

Thanks in advanced, greetings regards

Hi,

you need to clear the OKControlID property otherwise the postback won't be propagated to the server.

Grz, Kris.


I am having the same issue. I cleared the OKControlID and now my js is not running? Is there something else I need to do?

Hi Alice,

myNameIsAlice:

I cleared the OKControlID and now my js is not running?

which js isn't running? Know that clearing the OKControlID just makes it a normal postbacking control again.

Grz, Kris.

Monday, March 26, 2012

Modal Popup extender need help PLEASE - URGENT

I am having quite an issue with the modal popup extender, and I fear my situation is very unique.

I have an aspx page that has 2 update panels. The first update panel contains a dropdown box with a list of locations, I'll call this UPD1. The second update panel contains a webpart that contains a user control that lists contact information for the location selected, I'll call this UPD2. On this user control is a modal popup ajax control that displays a dialog to add new contacts for the location and it is loaded by clicking a button. When the page is first displayed and I click the add button in UPD2 the modal dialog displays just fine. If I change the loaction in UPD1, which causes UPD2 to be updated with contact information for the new location selected in UPD1 the add button in UPD2 no loger displays the modal dialog, but, causes a postback.

If I change the page containg these 2 update panels and remove the webpart from UPD2 and just place gthe user control in UPD2 the page works fine.

Any ideas? I am really stuck on this one.

Thanks,

Here as my user control.ascx code

<%@.ControlLanguage="VB"

AutoEventWireup="false"

CodeFile="NotificationList.ascx.vb"

Inherits="NotificationList"

%>

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

<%@.RegisterAssembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

Namespace="System.Web.UI"TagPrefix="asp" %>

<scripttype="text/javascript">

var vClearFields;

function fLoadRecipDialog(vNotificationID)

{

var vFirstName = document.getElementById("CMNFirstName" + vNotificationID);

alert ("vFirstName Is " + vFirstName);

alert ("vFirstName Value Is " + vFirstName.value);

var vLastName = document.getElementById("CMNLastName" + vNotificationID);

var vTitle = document.getElementById("CMNTitle" + vNotificationID);

var vEMail = document.getElementById("CMNEMail" + vNotificationID);

var vFrequency = document.getElementById("CMNFrequency" + vNotificationID);

var vFirstNameField = document.getElementById("WebPartManager1_gwpNotificationList_NotificationList_txtRecipFirstName");

vFirstNameField.value = vFirstName.value;

var vLastNameField = document.getElementById("WebPartManager1_gwpNotificationList_NotificationList_txtRecipLastName");

vLastNameField.value = vLastName.value;

var vTitleField = document.getElementById("WebPartManager1_gwpNotificationList_NotificationList_txtRecipTitle");

vTitleField.value = vTitle.value;

var vEMailField = document.getElementById("WebPartManager1_gwpNotificationList_NotificationList_txtRecipEMail");

vEMailField.value = vEMail.value;

var vFrequencyField = document.getElementById("WebPartManager1_gwpNotificationList_NotificationList_drpFrequency");

vFrequencyField.selectedIndex = parseFloat(vFrequency.value) - 1;

var vNotificationIDField = document.getElementById("WebPartManager1_gwpNotificationList_NotificationList_hdnNotificationID");

vNotificationIDField.value = vNotificationID;

vClearFields="N";

document.getElementById("WebPartManager1_gwpNotificationList_NotificationList_btnAddRecipient").click();

}

function fClearFields()

{

if (vClearFields !="N")

{

var vFirstNameField = document.getElementById("WebPartManager1_gwpNotificationList_NotificationList_txtRecipFirstName");

vFirstNameField.value ="";

var vLastNameField = document.getElementById("WebPartManager1_gwpNotificationList_NotificationList_txtRecipLastName");

vLastNameField.value ="";

var vTitleField = document.getElementById("WebPartManager1_gwpNotificationList_NotificationList_txtRecipTitle");

vTitleField.value ="";

var vEMailField = document.getElementById("WebPartManager1_gwpNotificationList_NotificationList_txtRecipEMail");

vEMailField.value ="";

var vFrequencyField = document.getElementById("WebPartManager1_gwpNotificationList_NotificationList_drpFrequency");

vFrequencyField.selectedIndex = parseFloat("0");

var vNotificationID = document.getElementById("WebPartManager1_gwpNotificationList_NotificationList_hdnNotificationID");

vNotificationID.value ="0";

}

// vTestObject = $find("TestExtender");

// alert(vTestObject);

// vTestObject.show();

vClearFields="Y";

returnfalse;

}

function fSaveRecip()

{

var vActionField = document.getElementById("WebPartManager1_gwpNotificationList_NotificationList_hdnAction");

var vIDField = document.getElementById("WebPartManager1_gwpNotificationList_NotificationList1_hdnID");

vActionField.value ="Save";

vIDField.value ="";

document.getElementById("WebPartManager1_gwpNotificationList_NotificationList_lnkDoPost").click();

}

function fDeleteRecip(vID)

{

var vActionField = document.getElementById("WebPartManager1_gwpNotificationList_NotificationList_hdnAction");

var vIDField = document.getElementById("WebPartManager1_gwpNotificationList_NotificationList_hdnID");

vActionField.value ="Delete";

vIDField.value = vID;

document.getElementById("WebPartManager1_gwpNotificationList_NotificationList_lnkDoPost").click();

}

</script>

<divclass="wpContent">

<asp:TableID="tblNotifications"runat="server"BorderStyle="solid"BorderWidth="1"Width="100%">

</asp:Table>

<center>

<asp:ButtonID="btnAddRecipient"runat="server"Text="Add"onclientclick='javascript: return fClearFields();'/>

<asp:LinkButtonID="lnkDoPost"runat="server"></asp:LinkButton>

<asp:LabelID="LabelCausedRefresh"runat="server"Width="184px"></asp:Label>

<asp:HiddenFieldID="hdnAction"runat="server"/>

<asp:HiddenFieldID="hdnID"runat="server"/>

</center>

<cc1:ModalPopupExtenderBehaviorID="TestExtender"ID="ModalPopupExtender1"runat="server"TargetControlID="btnAddRecipient"popupControlID="modalPanel"BackgroundCssClass="modalBackground"DropShadow="true"OkControlID="btnRecipSave"OnOkScript="fSaveRecip()"CancelControlID="btnRecipClose">

</cc1:ModalPopupExtender>

<divclass="modalPanel"id="modalPanel"style="display: none">

<asp:PanelID="pnlAddRecipient"runat="server"BorderWidth="1"Width="368px">

<tableborder="0"width="100%">

<tr>

<tdcolspan="2"align="center">

<b>Location Management - Notification Recipient</b>

</td>

</tr>

<tr>

<td>

</td>

<td>

</td>

</tr>

<tr>

<td>

<b>Location:</b>

</td>

<td>

<asp:LabelID="lblRecipLocationName"runat="server"Text="Label"Width="208px"></asp:Label>

</td>

</tr>

<tr>

<td>

<b>Name:</b>

</td>

<tdstyle="height: 26px">

<asp:TextBoxID="txtRecipFirstName"runat="server"Width="72px"></asp:TextBox>

<asp:TextBoxID="txtRecipLastName"runat="server"Width="128px"></asp:TextBox>

</td>

</tr>

<tr>

<td>

<b>Title:</b>

</td>

<td>

<asp:TextBoxID="txtRecipTitle"runat="server"Width="210px"></asp:TextBox>

</td>

</tr>

<tr>

<td>

<b>E-mail:</b>

</td>

<td>

<asp:TextBoxID="txtRecipEMail"runat="server"Width="210px"></asp:TextBox>

</td>

</tr>

<tr>

<td>

<b>Frequency:</b>

</td>

<td>

<asp:DropDownListID="drpFrequency"runat="server">

<asp:ListItemValue="1">Weekly</asp:ListItem>

<asp:ListItemValue="2">Bi-Weekly</asp:ListItem>

<asp:ListItemValue="3">Monthly</asp:ListItem>

</asp:DropDownList></td>

</tr>

<tr>

<tdcolspan="2"align="center">

<asp:LinkButtonID="btnRecipSave"runat="server">Save</asp:LinkButton>

<asp:LinkButtonID="btnRecipClose"runat="server">Close</asp:LinkButton>

<asp:HiddenFieldID="hdnNotificationID"runat="server"></asp:HiddenField>

</td>

</tr>

</table>

</asp:Panel>

</div>

</div>


Here is my ascx.vb code

Imports System.Data.SqlClient

Imports System.Data.OleDb

PartialClass NotificationList

Inherits System.Web.UI.UserControl

Dim cnRetailCommerceAs SqlConnection =Nothing

ProtectedSub Page_Load(ByVal senderAsObject,ByVal eAs System.EventArgs)HandlesMe.Load

Dim dsConsManageAsNew System.Data.DataSet

Dim cmdSelectAsNew SqlCommand

Dim parmCLocationAsNew SqlParameter("@.P_CLOCATION", Data.SqlDbType.VarChar, 50)

Dim daConsManageAsNew SqlDataAdapter

Dim tblRowAs TableRow

Dim tblCellAs TableCell

Dim m_aryFrequencies(3)AsString

m_aryFrequencies(1) ="Weekly"

m_aryFrequencies(2) ="Bi-Weekly"

m_aryFrequencies(3) ="Monthly"

LabelCausedRefresh.Text = Request.Form("__EventTarget")cnRetailCommerce =New SqlConnection(Session("CONNECTION"))

cnRetailCommerce.Open()

IfMe.IsPostBackThen

If Request.Form("__EventTarget").Contains("lnkDoPost")Then

SelectCase hdnAction.Value

Case"Delete"

DeleteConManageLocNotification()

Case"Save"

If hdnNotificationID.Value.ToString ="0"Then

CreateConManageLocNotification()

Else

UpdateConManageLocNotification()

EndIf

EndSelect

EndIf

EndIf

parmCLocation.Direction = Data.ParameterDirection.Input

parmCLocation.Value = Session("CMLocation")

cmdSelect.Connection = cnRetailCommerce

cmdSelect.CommandType = Data.CommandType.StoredProcedure

cmdSelect.CommandText ="USP_CONSMANAGEGETLOCNOTIFICATIONS"

cmdSelect.Parameters.Add(parmCLocation)

daConsManage.SelectCommand = cmdSelect

daConsManage.Fill(dsConsManage,"Notifications")

Dim dvConsManageAsNew System.Data.DataView(dsConsManage.Tables("Notifications"))

Dim drRowAs System.Data.DataRow

dvConsManage.RowFilter ="EMail='" & Session("EMAIL").ToString &"'"

If dvConsManage.Count = 0Then

tblRow =New TableRow

tblNotifications.Rows.Add(tblRow)

tblCell =New TableCell

tblCell.Text =" "

tblRow.Cells.Add(tblCell)

tblCell =New TableCell

tblCell.Text ="<a href='javascript:fLoadRecipDialog(" & Chr(34) &"0" & Chr(34) &");'>Add Me</a>"

tblRow.Cells.Add(tblCell)

tblCell =New TableCell

tblCell.Text ="<input type='hidden' name='CMNFirstName0' id='CMNFirstName0' value='" & Session("FIRSTNAME") &"'><input type='hidden' name='CMNLastName0' id='CMNLastName0' value='" & Session("LASTNAME") &"'><input type='hidden' name='CMNTitle0' id='CMNTitle0' value='" & Session("TITLE") &"'><input type='hidden' name='CMNEMail0' id='CMNEMail0' value='" & Session("EMAIL") &"'><input type='hidden' name='CMNFrequency0' id='CMNFrequency0' value='1'>"

tblRow.Cells.Add(tblCell)

EndIf

dvConsManage.Dispose()

If dsConsManage.Tables("Notifications").Rows.Count = 0Then

CreateDefaultConManageLocNotification()

EndIf

ForEach drRowIn dsConsManage.Tables("Notifications").Rows

If drRow("UserManageable") =TrueThen

tblRow =New TableRow

tblNotifications.Rows.Add(tblRow)

tblCell =New TableCell

tblCell.Text ="<a href='javascript:fDeleteRecip(" & Chr(34) & drRow("NotificationID") & Chr(34) &");'><IMG Src='images\red_x_trans.gif' border='0' height='10px' width='10px'></a>"

tblRow.Cells.Add(tblCell)

tblCell =New TableCell

tblCell.Text ="<a href='javascript:fLoadRecipDialog(" & Chr(34) & drRow("NotificationID") & Chr(34) &");'>" & drRow("FirstName") &" " & drRow("LastName") &"</a>"

tblRow.Cells.Add(tblCell)

tblCell =New TableCell

tblCell.Text = m_aryFrequencies(drRow("Frequency")) &"<input type='hidden' name='CMNFirstName" & drRow("NotificationID") &"' id='CMNFirstName" & drRow("NotificationID") &"' value='" & drRow("FirstName") &"'><input type='hidden' name='CMNLastName" & drRow("NotificationID") &"' id='CMNLastName" & drRow("NotificationID") &"' value='" & drRow("LastName") &"'><input type='hidden' name='CMNTitle" & drRow("NotificationID") &"' id='CMNTitle" & drRow("NotificationID") &"' value='" & drRow("Title") &"'><input type='hidden' name='CMNEMail" & drRow("NotificationID") &"' id='CMNEMail" & drRow("NotificationID") &"' value='" & drRow("EMail") &"'><input type='hidden' name='CMNFrequency" & drRow("NotificationID") &"' id='CMNFrequency" & drRow("NotificationID") &"' value='" & drRow("Frequency") &"'>"

tblRow.Cells.Add(tblCell)

EndIf

Next

tblRow =New TableRow

tblNotifications.Rows.Add(tblRow)

tblCell =New TableCell

tblCell.Text = hdnAction.Value

tblRow.Cells.Add(tblCell)

tblCell =New TableCell

tblCell.Text = Now.ToString

tblRow.Cells.Add(tblCell)

tblCell =New TableCell

tblCell.Text = hdnID.Value

tblRow.Cells.Add(tblCell)

dsConsManage.Dispose()

daConsManage.Dispose()

cnRetailCommerce.Close()

cnRetailCommerce.Dispose()

hdnID.Value =""

hdnAction.Value =""

EndSub

PrivateSub CreateDefaultConManageLocNotification()

Dim cmdUpdateAsNew SqlCommand

Dim parmCLocationAsNew SqlParameter("@.P_CLOCATION", Data.SqlDbType.VarChar, 50)

Dim parmFirstNameAsNew SqlParameter("@.P_FIRSTNAME", Data.SqlDbType.VarChar, 20)

Dim parmLastNameAsNew SqlParameter("@.P_LASTNAME", Data.SqlDbType.VarChar, 50)

Dim parmTitleAsNew SqlParameter("@.P_TITLE", Data.SqlDbType.VarChar, 50)

Dim parmEMailAsNew SqlParameter("@.P_EMAIL", Data.SqlDbType.VarChar, 255)

Dim parmFrequencyAsNew SqlParameter("@.P_FREQUENCY", Data.SqlDbType.Int)

Dim parmUserManageableAsNew SqlParameter("@.P_USERMANAGEABLE", Data.SqlDbType.Int)

parmCLocation.Direction = Data.ParameterDirection.Input

parmCLocation.Value = Session("CMLocation")

parmFirstName.Direction = Data.ParameterDirection.Input

parmFirstName.Value ="John"

parmLastName.Direction = Data.ParameterDirection.Input

parmLastName.Value ="Romeo"

parmTitle.Direction = Data.ParameterDirection.Input

parmTitle.Value ="AWT Consignment Inventory Manager"

parmEMail.Direction = Data.ParameterDirection.Input

parmEMail.Value ="JRomeo@.harsco.com"

parmFrequency.Direction = Data.ParameterDirection.Input

parmFrequency.Value = 1

parmUserManageable.Direction = Data.ParameterDirection.Input

parmUserManageable.Value = 0

cmdUpdate.Connection = cnRetailCommerce

cmdUpdate.CommandType = Data.CommandType.StoredProcedure

cmdUpdate.CommandText ="USP_CONSMANAGECREATELOCNOTIFICATIONS"

cmdUpdate.Parameters.Add(parmCLocation)

cmdUpdate.Parameters.Add(parmFirstName)

cmdUpdate.Parameters.Add(parmLastName)

cmdUpdate.Parameters.Add(parmTitle)

cmdUpdate.Parameters.Add(parmEMail)

cmdUpdate.Parameters.Add(parmFrequency)

cmdUpdate.Parameters.Add(parmUserManageable)

cmdUpdate.ExecuteNonQuery()

cmdUpdate.Dispose()

EndSub

PrivateSub CreateConManageLocNotification()

Dim cmdUpdateAsNew SqlCommand

Dim parmCLocationAsNew SqlParameter("@.P_CLOCATION", Data.SqlDbType.VarChar, 50)

Dim parmFirstNameAsNew SqlParameter("@.P_FIRSTNAME", Data.SqlDbType.VarChar, 20)

Dim parmLastNameAsNew SqlParameter("@.P_LASTNAME", Data.SqlDbType.VarChar, 50)

Dim parmTitleAsNew SqlParameter("@.P_TITLE", Data.SqlDbType.VarChar, 50)

Dim parmEMailAsNew SqlParameter("@.P_EMAIL", Data.SqlDbType.VarChar, 255)

Dim parmFrequencyAsNew SqlParameter("@.P_FREQUENCY", Data.SqlDbType.Int)

Dim parmUserManageableAsNew SqlParameter("@.P_USERMANAGEABLE", Data.SqlDbType.Int)

parmCLocation.Direction = Data.ParameterDirection.Input

parmCLocation.Value = Session("CMLocation")

parmFirstName.Direction = Data.ParameterDirection.Input

parmFirstName.Value = txtRecipFirstName.Text

parmLastName.Direction = Data.ParameterDirection.Input

parmLastName.Value = txtRecipLastName.Text

parmTitle.Direction = Data.ParameterDirection.Input

parmTitle.Value = txtRecipTitle.Text

parmEMail.Direction = Data.ParameterDirection.Input

parmEMail.Value = txtRecipEMail.Text

parmFrequency.Direction = Data.ParameterDirection.Input

parmFrequency.Value = drpFrequency.SelectedValue

parmUserManageable.Direction = Data.ParameterDirection.Input

parmUserManageable.Value = 1

cmdUpdate.Connection = cnRetailCommerce

cmdUpdate.CommandType = Data.CommandType.StoredProcedure

cmdUpdate.CommandText ="USP_CONSMANAGECREATELOCNOTIFICATIONS"

cmdUpdate.Parameters.Add(parmCLocation)

cmdUpdate.Parameters.Add(parmFirstName)

cmdUpdate.Parameters.Add(parmLastName)

cmdUpdate.Parameters.Add(parmTitle)

cmdUpdate.Parameters.Add(parmEMail)

cmdUpdate.Parameters.Add(parmFrequency)

cmdUpdate.Parameters.Add(parmUserManageable)

cmdUpdate.ExecuteNonQuery()

cmdUpdate.Dispose()

EndSub

PrivateSub DeleteConManageLocNotification()

Dim cmdUpdateAsNew SqlCommand

Dim parmNotificationIDAsNew SqlParameter("@.P_NOTIFICATIONID", Data.SqlDbType.Int)

parmNotificationID.Direction = Data.ParameterDirection.Input

parmNotificationID.Value = hdnID.Value

cmdUpdate.Connection = cnRetailCommerce

cmdUpdate.CommandType = Data.CommandType.StoredProcedure

cmdUpdate.CommandText ="USP_CONSMANAGEDELETELOCNOTIFICATIONS"

cmdUpdate.Parameters.Add(parmNotificationID)

cmdUpdate.ExecuteNonQuery()

cmdUpdate.Dispose()

EndSub

PrivateSub UpdateConManageLocNotification()

Dim cmdUpdateAsNew SqlCommand

Dim parmNotificationIDAsNew SqlParameter("@.P_NOTIFICATIONID", Data.SqlDbType.Int)

Dim parmCLocationAsNew SqlParameter("@.P_CLOCATION", Data.SqlDbType.VarChar, 50)

Dim parmFirstNameAsNew SqlParameter("@.P_FIRSTNAME", Data.SqlDbType.VarChar, 20)

Dim parmLastNameAsNew SqlParameter("@.P_LASTNAME", Data.SqlDbType.VarChar, 50)

Dim parmTitleAsNew SqlParameter("@.P_TITLE", Data.SqlDbType.VarChar, 50)

Dim parmEMailAsNew SqlParameter("@.P_EMAIL", Data.SqlDbType.VarChar, 255)

Dim parmFrequencyAsNew SqlParameter("@.P_FREQUENCY", Data.SqlDbType.Int)

parmNotificationID.Direction = Data.ParameterDirection.Input

parmNotificationID.Value = hdnNotificationID.Value

parmCLocation.Direction = Data.ParameterDirection.Input

parmCLocation.Value = Session("CMLocation")

parmFirstName.Direction = Data.ParameterDirection.Input

parmFirstName.Value = txtRecipFirstName.Text

parmLastName.Direction = Data.ParameterDirection.Input

parmLastName.Value = txtRecipLastName.Text

parmTitle.Direction = Data.ParameterDirection.Input

parmTitle.Value = txtRecipTitle.Text

parmEMail.Direction = Data.ParameterDirection.Input

parmEMail.Value = txtRecipEMail.Text

parmFrequency.Direction = Data.ParameterDirection.Input

parmFrequency.Value = drpFrequency.SelectedValue

cmdUpdate.Connection = cnRetailCommerce

cmdUpdate.CommandType = Data.CommandType.StoredProcedure

cmdUpdate.CommandText ="USP_CONSMANAGEUPDATELOCNOTIFICATIONS"

cmdUpdate.Parameters.Add(parmNotificationID)

cmdUpdate.Parameters.Add(parmCLocation)

cmdUpdate.Parameters.Add(parmFirstName)

cmdUpdate.Parameters.Add(parmLastName)

cmdUpdate.Parameters.Add(parmTitle)

cmdUpdate.Parameters.Add(parmEMail)

cmdUpdate.Parameters.Add(parmFrequency)

cmdUpdate.ExecuteNonQuery()

cmdUpdate.Dispose()

EndSub

EndClass


Bump - I have a huge need to get this working. can someone please help?

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

Saturday, March 24, 2012

ModalDialogExtender wish

I wish we could have a way to have a modaldialog that had a TargetUrl property that could use a separte aspx page as the source of it's ui. I have a page that has several dialogs and having to jam all that code on one page sure is messy.

I wish, I wish.

Why not use an ascx for each modalpopup?

Wednesday, March 21, 2012

ModalPopup - how to prevent interaction with page?

In the example onhttp://ajax.asp.net/ajaxtoolkit/ModalPopup/ModalPopup.aspx the ModalPopup prevents interaction with the page. If I copy and paste that code, the panel shows but I still can interact with the page, respectively the control elements in the back. What do I need to apply to make this work like in the example? How do I block the interaction (except with the newly opened panel)Any hint highly appreciated.

<asp:ScriptManagerid="ScriptManager1"runat="server"></asp:ScriptManager><asp:UpdatePanelid="UpdatePanel1"runat="server"><contenttemplate>

<

ajaxToolkit:ModalPopupExtenderid="ModalPopupExtender1"runat="server"CancelControlID="ButtonCancel"OnOkScript="onOk()"OkControlID="ButtonOK"DropShadow="true"PopupControlID="PanelRentals"TargetControlID="ButtonGo"BackgroundCssClass="modalBackground"> ></ajaxToolkit:ModalPopupExtender><asp:Panelid="PanelRentals"runat="server"Height="50px"Width="125px"BorderStyle="Solid"><asp:Labelid="Label1"runat="server"Text="Rentals"></asp:Label> <asp:Buttonid="ButtonCancel"runat="server"Text="Cancel"></asp:Button><asp:Buttonid="ButtonOk"runat="server"Text="OK"></asp:Button></asp:Panel><asp:Buttonid="ButtonGo"runat="server"Text="Button"></asp:Button>

</

contenttemplate></asp:UpdatePanel>

You need to define a CSS class for the BackgroundCssClass property (named "modalBackground" in the snippet above). SampleWebSite does this in StyleSheet.css as:

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