Showing posts with label button. Show all posts
Showing posts with label button. Show all posts

Wednesday, March 28, 2012

control inside an update panel not updated

i have a dropdown list inside an update panel of ajax, i have a button that says "Add" on the click event of the button i will load a pop-up screen. the popup screen works as entry area of the drop down list i have mentioned. upon saving and unloading the pop-up screen, it should update the dropdown list contents. any help please, this is my first time to handle ajax..

Hi,

You question is about cross window scripting.

First, find the dropdownlist in the parent control.

var ddl = window.opener.document.getElementById("id of the ddl");

then add new item into it:

ddl.options.add("new value");

Hope this helps.

Monday, March 26, 2012

Connect AnimationExtender at runtime

Hi,

I have created a page with a datalist that has a button and a image inside the itemtemplate. So what I trying to do is to connect the animationextender with the button (targetid) at runtime, wich does not work at all. Is it possible to connect (set target id) at runtime or must it be done in designtime?

//CC

Hi TCNC,

The Animation Framework has a n undocumented feature wherein any attribute assigned to the AnimationExtender is evaluated at runtime .

You can use it by suffixing the Attribute with the Attribute "Script"

EX: < ajaxToolkit:AnimationExtender Blah>

<OnClick>

<Resize Height="200" width="200" AnimationTargetScript="getTargetElement();" />

</OnClick>

</ajaxToolkit:AnimationExtender>

<script language="Javascript">

function getTargetElement(){

return someelementID;

}

</script>

This will cause the function getTargetElement to be called whenever the Animation is played.

You can probably set the ID of the Element to be animated in a hidden field.

In the Function "getTargetElement" read the HiddenField and return its value.

When the Animation plays , the target is automatically changed.

Hope this helps.

And if it resolves the issue , Please mark my reply as the answer

confirmbuttonextender-advanced

I am using a confirm button extender to fire before the user updates a database. What I would like to do is gather all of the "changes" that will be made and display them in the alert...

Example:

--button 1 sub--

confirmbuttonextender1.confirmtext = textbox1.text & textbox2.text & dropdown1.selectedvalue etc.


Here is the problem... the string is not persisted until a postback takes place... so before someone says use a partial page update or anything that triggers an update... don't... ;)

so basically I need a way to gather the information from the objects BEFORE a postback takes place so that when the user clicks the button the alert will tell the user what changes are about to be made.

Thanks for the help!

You're right, it won't work with server-side script. It would be very simple to write your own javascript confirm and forget about the extender.

------------------
When you ask a question, remember to click "mark as answered" when you get a reply which answers your question.


yeah... not quite so simple....

anymore help would be great

ConfirmButtonExtender with Validators ?

Hi -

does anyone know how to make the confirmbutton extender conditionnal on the validation of the page?

For instance, i've got a button with confirm extender that posts information entered in TextBoxes. Some of those textboxes have validators - so the post won't happen if the textboxes aren't correctly filled in (so i don't need an active confirmation in that case). If the boxes are correctly filled in, then i would like the confirmButtonExtender to be active...

Anyway to make that happen?

thanks for the help!

-bash

I believe this would take some additional code in ConfirmButtonBehavior.js. If you happen to implement the feature, we'd love to include it in the Toolkit!

//
// Custom methods
//ADD this bold text to this function and recompile control toolkit tool - this will first validate the page then display the confirmation dialog

_onClick : function(e) {
if (this.get_element() && !this.get_element().disabled) {
// Display confirm dialog and return result to allow cancellation

if(Page_ClientValidate()) {

if (!window.confirm(this._ConfirmTextValue)) {
e.preventDefault();
return false;
}
}
}
},


this is *.js - i have forgot to put rest code - here it is

PART ONE

_onClick :

function(e) {if (this.get_element() && !this.get_element().disabled) {// Display confirm dialog and return result to allow cancellation

if(this._checkValidatorsValue)

{

if(Page_ClientValidate()) {

if (!window.confirm(this._ConfirmTextValue)) {

e.preventDefault();

returnfalse;

}

}

}

else

{

if (!window.confirm(this._ConfirmTextValue)) {

e.preventDefault();

returnfalse;

}

}

}

},

//// Property get/set methods//

get_ConfirmText :

function() {returnthis._ConfirmTextValue;

},

set_ConfirmText :

function(value) {if (this._ConfirmTextValue != value) {this._ConfirmTextValue = value;this.raisePropertyChanged('ConfirmText');

}

},

get_checkValidators :

function() {returnthis._checkValidatorsValue;

},

set_checkValidators :

function(value) {if (this._checkValidatorsValue != value) {this._checkValidatorsValue = value;this.raisePropertyChanged('checkValidators');

}

}

PART TWO - add this to this file *.cs

[

ExtenderControlProperty()]publicbool checkValidators

{

get

{

return GetPropertyBoolValue("checkValidators");

}

set

{

SetPropertyBoolValue(

"checkValidators",value);

}

}

PART THREE

NOW IF YOU WANT TO USE CONFIRM DIALOG WITH VALIDATORS YOU SHOUL SET IN ASPX FILE IN CONFIRMBUTTONEXTANDER PROPERTY CHECKVALIDATORS TO TRUE

IF YOU WANT TO USE CONFIRM DIALOG WITHOUT VALIDATORS (FOR EXAMPLE ON PAGE THERE ARE NOT VALIDATORS) SET THIS PROPERTY TO FALSE


Related to my reply inthis thread, I believe. The code here seems to be a move along the path to add the mentioned submit event support to ConfirmButton.


FYI, I've just fixed this issue:http://www.codeplex.com/WorkItem/View.aspx?ProjectName=AtlasControlToolkit&WorkItemId=8342.

ConfirmButtonExtender inside templatefield inside gridview gives an error but works fine

Inside a gridview i have a button to delete a record (button 3). There is a ConfirmButtonExtender to prevent a administator from deleting the wrong record.

This works fine, but the page gives an error (IE6 in the statusbar). Also some TextBoxWatermarkExtenders placed after the gridview only work after a postback. When I take out the ConfirmButtonExtender it works fine. I can't place the ConfirmButtonExtender outside the gridview because it doesn;t find button3 than.

Anyone? By the way: the ConfirmButtonExtender does work like it's supposed to!

... <asp:TemplateField Visible="False" ShowHeader="False"> <ItemStyle Width="35px" HorizontalAlign="Left"></ItemStyle> <ItemTemplate> <asp:Button ID="Button3" runat="server" Style="background-attachment: fixed; background-color: transparent; background-image: url(http://blabla.gif); background-repeat:no-repeat ; border-top-width: thin; border-left-width: thin; border-left-color: moccasin; border-bottom-width: thin; border-bottom-color: moccasin; border-top-color: moccasin; border-right-width: thin; border-right-color: moccasin;" Width="32px" tooltip="Verwijder WV (definitief!!!!!)" CommandArgument='<%# eval("Kop1AlgVpNummer")%>' Height="30px" OnCommand="Button3_Command" BorderColor="#FFE0C0" BorderStyle="None" /> <ajaxToolkit:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server" TargetControlID="Button3" ConfirmText="Zeker weten?"></ajaxToolkit:ConfirmButtonExtender> </ItemTemplate> </asp:TemplateField>...

Seems to work fine for me (the error on postback's just due to the way I create the data):

<%@. Page Language="C#" AutoEventWireup="true" Title="Controls in a Repeater Tests" %><script runat="server"> protected void Page_Load(object sender, EventArgs e) { System.Data.DataTable table = new System.Data.DataTable(); table.Columns.Add(new System.Data.DataColumn("Value", typeof(string))); foreach (string value in "one,two,three,four,five".Split(',')) { System.Data.DataRow row = table.NewRow(); row["Value"] = value; table.Rows.Add(row); } Repeater1.DataSource = new System.Data.DataView(table); Repeater1.DataBind(); }</script><%@. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %><!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 id="Head1" runat="server"> <title>Sample Page</title></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="SM" runat="server" /> <asp:Repeater ID="Repeater1" runat="server"> <ItemTemplate> <asp:Button ID="Button" runat="server" Text='<%# Eval("Value")%>' /> <ajaxToolkit:ConfirmButtonExtender ID="CBE" runat="server" TargetControlID="Button" ConfirmText='<%# Eval("Value")+" - Really?"%>' /> <hr /> </ItemTemplate> </asp:Repeater> </form></body></html>

Mmmm, maybe I should add that my gridview is inside an updatepanel also? Yours' is in a repeater......

Or should I paste the complete code?


 OK, here is the complete code: 
1<%@. Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="overzicht.aspx.vb" Inherits="_overzicht" %>2<%@. MasterType virtualpath="~/Masterpage.master" %>34<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder3" Runat="Server">5 <asp:ScriptManager runat="server" id="SC1"></asp:ScriptManager>6 <div>7 <asp:UpdatePanel ID="UpdatePanel1" runat="server">8 <ContentTemplate>9 <em><span style="FONT-SIZE: 8pt; COLOR: #006600">10 <asp:Label ID="Label8" runat="server" Font-Size="8pt" Text="Status:"></asp:Label><br/>11 <asp:DropDownList style="FONT-SIZE: 8pt; FONT-FAMILY: 'Lucida Sans'" id="ddl_snel" runat="server" Width="49px" Height="19px" AutoPostBack="True" OnSelectedIndexChanged="ddl_snel_SelectedIndexChanged">12 <asp:ListItem ><=3</asp:ListItem>13 <asp:ListItem >=3</asp:ListItem>14 <asp:ListItem >=2</asp:ListItem>15 <asp:ListItem >=1</asp:ListItem>16 <asp:ListItem >=0</asp:ListItem>17 </asp:DropDownList></span></em>18<br/>19 <asp:GridView id="GridView_s" runat="server" Width="56px" AllowPaging="True" ShowHeader="False" PageSize="30" HorizontalAlign="Left" Height="600px" GridLines="None" DataSourceID="SqlDataSource_s" DataKeyNames="Kop1AlgVpnummer" AutoGenerateColumns="False" Font-Size="8pt" Font-Strikeout="False">20 <Columns>21 <asp:TemplateField>22 <ItemTemplate>23 <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# Eval("Kop1AlgVpNummer", "~/MemberPaginas/details.aspx?WVnummer={0}")%>'24 Text='<%# Eval("Kop1AlgVpnummer", "{0}")%>' ToolTip='<%# Eval("titel")%>'></asp:HyperLink>25 </ItemTemplate>26 </asp:TemplateField>27 </Columns>28 <PagerSettings Mode="NextPreviousFirstLast" />29 <RowStyle HorizontalAlign="Left" VerticalAlign="Top" Font-Italic="True" Font-Size="8pt" ForeColor="Maroon" />30 <PagerStyle Font-Size="7pt" Font-Overline="False" />31 </asp:GridView>32<asp:SqlDataSource ID="SqlDataSource_s" runat="server" ConnectionString="<%$ ConnectionStrings:WV-ConnectionString%>"33 SelectCommand="SELECT Kop1AlgVpnummer, titel FROM DATA WHERE (status <= 3) ORDER BY Kop1AlgVpnummer DESC">34</asp:SqlDataSource>3536 </ContentTemplate>37 </asp:UpdatePanel>38 </div>39</asp:Content>4041<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">42 <div style="FONT-SIZE: 8pt"><br />43 <asp:UpdatePanel runat="server" id="up2">44 <ContentTemplate>45 <asp:Button style="LEFT: 0px; POSITION: relative; TOP: -21px" id="Button6" runat="server" Text="print overzicht (PDF)" Font-Size="8pt" Font-Bold="True" Width="132px" ForeColor="#FF0000" BackColor="#0000C0" ToolTip="Print huidige overzicht..."></asp:Button>46 <asp:Button style="LEFT: 94px; CURSOR: hand; POSITION: relative; TOP: -21px" id="Button4" runat="server" Text="Mijn WV's" Font-Size="8pt" Font-Bold="True" BorderStyle="Ridge" ForeColor="#0000C0" BackColor="#FFC080" ToolTip="Laat alleen 'mijn WV's' zien" Height="19px" BorderColor="#FF8000"></asp:Button>47 <asp:Button style="LEFT: 495px; CURSOR: hand; FONT-FAMILY: 'Lucida Sans'; POSITION: relative; TOP: -21px" id="Button2" runat="server" Text="Reset filters" Font-Size="8pt" Font-Bold="True" BorderStyle="Ridge" Width="123px" ForeColor="#0000C0" BackColor="#FFC080" ToolTip="Reset alle filters en geef het toaal overzicht weer" BorderColor="#FF8000"></asp:Button>  48 <asp:Button style="BORDER-TOP-WIDTH: thin; BORDER-LEFT-WIDTH: thin; BORDER-LEFT-COLOR: moccasin; BACKGROUND-ATTACHMENT: fixed; LEFT: 183px; BACKGROUND-IMAGE: url(http://eb-service/WV/MemberPaginas/images/vraagteken.gif); BORDER-BOTTOM-WIDTH: thin; BORDER-BOTTOM-COLOR: moccasin; CURSOR: hand; BORDER-TOP-COLOR: moccasin; BACKGROUND-REPEAT: no-repeat; POSITION: relative; TOP: -17px; BACKGROUND-COLOR: transparent; BORDER-RIGHT-WIDTH: thin; BORDER-RIGHT-COLOR: moccasin" id="Button_help4" runat="server" Font-Size="8pt" BorderStyle="None" Width="21px" Height="24px" BorderColor="#FFE0C0" tooltip="info..."></asp:Button>49 <asp:Button style="BORDER-TOP-WIDTH: thin; BORDER-LEFT-WIDTH: thin; BORDER-LEFT-COLOR: moccasin; BACKGROUND-ATTACHMENT: fixed; LEFT: -240px; BACKGROUND-IMAGE: url(http://eb-service/WV/MemberPaginas/images/vraagteken.gif); BORDER-BOTTOM-WIDTH: thin; BORDER-BOTTOM-COLOR: moccasin; CURSOR: hand; BORDER-TOP-COLOR: moccasin; BACKGROUND-REPEAT: no-repeat; POSITION: relative; TOP: -18px; BACKGROUND-COLOR: transparent; BORDER-RIGHT-WIDTH: thin; BORDER-RIGHT-COLOR: moccasin" id="Button_help5" runat="server" Font-Size="8pt" BorderStyle="None" Width="21px" Height="24px" BorderColor="#FFE0C0" tooltip="info..."></asp:Button>50 <asp:Button style="BORDER-TOP-WIDTH: thin; BORDER-LEFT-WIDTH: thin; BORDER-LEFT-COLOR: moccasin; BACKGROUND-ATTACHMENT: fixed; LEFT: 106px; BACKGROUND-IMAGE: url(http://eb-service/WV/MemberPaginas/images/vraagteken.gif); BORDER-BOTTOM-WIDTH: thin; BORDER-BOTTOM-COLOR: moccasin; CURSOR: hand; BORDER-TOP-COLOR: moccasin; BACKGROUND-REPEAT: no-repeat; POSITION: relative; TOP: 20px; BACKGROUND-COLOR: transparent; BORDER-RIGHT-WIDTH: thin; BORDER-RIGHT-COLOR: moccasin" id="Button_help6" runat="server" Font-Size="8pt" BorderStyle="None" Width="21px" Height="24px" BorderColor="#FFE0C0" tooltip="info..."></asp:Button> <BR />51 <asp:DropDownList style="LEFT: 1px; CURSOR: hand; POSITION: relative; TOP: -7px" id="DDL_nummer" runat="server" Font-Size="9pt" Width="87px" ToolTip="Filter: geeft alleen de geselecteerde WV weer" AutoPostBack="True" DataSourceID="SqlDataSource2" AppendDataBoundItems="True" DataTextField="Kop1AlgVpnummer" DataValueField="Kop1AlgVpnummer">52 <asp:ListItem Value="0">geen filter</asp:ListItem>53 </asp:DropDownList>54 <asp:DropDownList style="LEFT: 18px; CURSOR: hand; POSITION: relative; TOP: -7px" id="DDL_aanvrager" runat="server" Font-Size="8pt" Width="133px" ToolTip="Filter: geeft alleen de WV's met de geselecteerde aanvrager weer" AutoPostBack="True" DataSourceID="SqlDataSource3" AppendDataBoundItems="True" DataTextField="Achternaam" DataValueField="asp_naam">55 <asp:ListItem Selected="True" Value="0">geen filter</asp:ListItem>56 </asp:DropDownList>57 <asp:TextBox style="LEFT: 50px; CURSOR: text; POSITION: relative; TOP: -9px" id="LokatieTextBox" runat="server" Font-Size="8pt" Width="112px" ToolTip="Filter: geeft alleen de WV's weer waarin zoekterm voor komt (veld: locatie)"></asp:TextBox>58 <asp:Button style="BORDER-TOP-WIDTH: thin; BORDER-LEFT-WIDTH: thin; BORDER-LEFT-COLOR: background; BACKGROUND: url(http://eb-service/WV/MemberPaginas/images/oogjes.gif) yellow fixed repeat-y center center; LEFT: 118px; BORDER-BOTTOM-WIDTH: thin; BORDER-BOTTOM-COLOR: background; OVERFLOW: hidden; CURSOR: hand; BORDER-TOP-COLOR: background; POSITION: relative; TOP: -4px; BORDER-RIGHT-WIDTH: thin; BORDER-RIGHT-COLOR: background" id="zoek1Button" onclick="zoek1" runat="server" Width="38px" Height="21px" tooltip="Zoek!"></asp:Button>59 <asp:Button style="LEFT: 7px; CURSOR: hand; POSITION: relative; TOP: -9px" id="Button1" runat="server" Text="reset" Font-Size="7pt" Font-Bold="True" ForeColor="#FF0000" ToolTip="Reset locatiefilter + overzicht"></asp:Button>60 <asp:TextBox style="LEFT: 123px; CURSOR: text; POSITION: relative; TOP: -8px" id="RedenTextBox" runat="server" Font-Size="8pt" Width="139px" ToolTip="Filter: geeft alleen de WV's weer waarin zoekterm voor komt (veld: Werk/reden)"></asp:TextBox>61 <asp:Button style="LEFT: 121px; CURSOR: hand; POSITION: relative; TOP: -9px" id="Button8" runat="server" Text="reset" Font-Size="7pt" Font-Bold="True" ForeColor="#FF0000" ToolTip="Reset werk/reden-filter + overzicht"></asp:Button>62 <asp:Label style="LEFT: -190px; POSITION: relative; TOP: 22px; TEXT-ALIGN: right" id="AantalLabel" runat="server" Font-Size="12pt" Font-Bold="True" Width="151px" ForeColor="#FF0033" BackColor="#0000CC"></asp:Label>63 <asp:DropDownList style="LEFT: -313px; CURSOR: hand; POSITION: relative; TOP: -40px" id="JaarDropDownList" runat="server" Font-Size="9pt" Width="84px" ForeColor="Yellow" BackColor="Red" ToolTip="Filter: geeft alleen de WV's met het geselecteerde jaar weer" AutoPostBack="True">64 <asp:ListItem Value="0">Geen filter</asp:ListItem>65 <asp:ListItem Value="1">2006</asp:ListItem>66 <asp:ListItem Value="2">2007</asp:ListItem>67 </asp:DropDownList>68 <asp:DropDownList style="LEFT: 61px; CURSOR: hand; POSITION: relative; TOP: -5px" id="DDL_status" runat="server" Font-Size="9pt" Width="56px" ToolTip="Filter: geeft alleen de WV's met de geselecteerde status weer" AutoPostBack="True">69 <asp:ListItem Value="0">= 0</asp:ListItem>70 <asp:ListItem Value="1">= 1</asp:ListItem>71 <asp:ListItem Value="2"><= 1</asp:ListItem>72 <asp:ListItem Value="3">= 2</asp:ListItem>73 <asp:ListItem Value="4"><= 2</asp:ListItem>74 <asp:ListItem Value="5">= 3</asp:ListItem>75 <asp:ListItem Value="6"><= 3</asp:ListItem>76 <asp:ListItem Value="7">= 4</asp:ListItem>77 <asp:ListItem Value="8"><= 4</asp:ListItem>78 <asp:ListItem Value="9">= 5</asp:ListItem>79 <asp:ListItem Value="10"><= 5</asp:ListItem>80 </asp:DropDownList>81 <asp:Button style="BORDER-TOP-WIDTH: thin; BORDER-LEFT-WIDTH: thin; BORDER-LEFT-COLOR: moccasin; BACKGROUND-ATTACHMENT: fixed; LEFT: 60px; BACKGROUND-IMAGE: url(http://eb-service/WV/MemberPaginas/images/vraagteken.gif); BORDER-BOTTOM-WIDTH: thin; BORDER-BOTTOM-COLOR: moccasin; CURSOR: hand; BORDER-TOP-COLOR: moccasin; BACKGROUND-REPEAT: no-repeat; POSITION: relative; TOP: -5px; BACKGROUND-COLOR: transparent; BORDER-RIGHT-WIDTH: thin; BORDER-RIGHT-COLOR: moccasin" id="Button_help" runat="server" Font-Size="8pt" BorderStyle="None" Width="21px" Height="24px" BorderColor="#FFE0C0" tooltip="info..."></asp:Button>82 <asp:Button style="BORDER-TOP-WIDTH: thin; BORDER-LEFT-WIDTH: thin; BORDER-LEFT-COLOR: moccasin; BACKGROUND-ATTACHMENT: fixed; LEFT: -690px; BACKGROUND-IMAGE: url(http://eb-service/WV/MemberPaginas/images/vraagteken.gif); BORDER-BOTTOM-WIDTH: thin; BORDER-BOTTOM-COLOR: moccasin; CURSOR: hand; BORDER-TOP-COLOR: moccasin; BACKGROUND-REPEAT: no-repeat; POSITION: relative; TOP: -5px; BACKGROUND-COLOR: transparent; BORDER-RIGHT-WIDTH: thin; BORDER-RIGHT-COLOR: moccasin" id="Button_help2" runat="server" Font-Size="8pt" BorderStyle="None" Width="21px" Height="23px" BorderColor="#FFE0C0" tooltip="info..."></asp:Button>83 <asp:Button style="BORDER-TOP-WIDTH: thin; BORDER-LEFT-WIDTH: thin; BORDER-LEFT-COLOR: moccasin; BACKGROUND-ATTACHMENT: fixed; LEFT: -866px; BACKGROUND-IMAGE: url(http://eb-service/WV/MemberPaginas/images/vraagteken.gif); BORDER-BOTTOM-WIDTH: thin; BORDER-BOTTOM-COLOR: moccasin; CURSOR: hand; BORDER-TOP-COLOR: moccasin; BACKGROUND-REPEAT: no-repeat; POSITION: relative; TOP: -6px; BACKGROUND-COLOR: transparent; BORDER-RIGHT-WIDTH: thin; BORDER-RIGHT-COLOR: moccasin" id="Button_help3" runat="server" Font-Size="8pt" BorderStyle="None" Width="21px" Height="24px" BorderColor="#FFE0C0" tooltip="info..."></asp:Button>84 <asp:GridView id="GridView1" runat="server" BorderWidth="1px" BorderStyle="Groove" Width="1000px" ForeColor="Black" BackColor="PapayaWhip" AutoGenerateColumns="False" DataKeyNames="Kop1AlgVpnummer" PageSize="8" AllowPaging="True" BorderColor="Tan" AllowSorting="True" CellPadding="2" EmptyDataText="Geen data!" OnPageIndexChanging="GridView1_PageIndexChanging" OnSorting="GridView1_Sorting">85 <PagerSettings PageButtonCount="30" Mode="NumericFirstLast"></PagerSettings>86 <FooterStyle BackColor="Tan"></FooterStyle>87 <Columns>88 <asp:TemplateField SortExpression="Kop1AlgVpnummer" HeaderText="WV:">89 <ItemStyle BackColor="SandyBrown" Width="60px" HorizontalAlign="Center" Font-Bold="True"></ItemStyle>90 <ItemTemplate>91 <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# Eval("Kop1AlgVpnummer", "details.aspx?WVnummer={0}")%>'92 Text='<%# Eval("Kop1AlgVpnummer")%>' ToolTip='<%# Eval("titel")%>'></asp:HyperLink>93 <br />94 <asp:Button ID="Button7" runat="server" CommandArgument='<%# Eval("Kop1AlgVpnummer")%>'95 Font-Bold="True" Font-Size="7pt" ForeColor="Red" Height="15px" OnCommand="pdf_maak"96 Style="font-family: 'Lucida Sans'" Text="PDF" Width="30px" />97 </ItemTemplate>98 </asp:TemplateField>99 <asp:TemplateField SortExpression="Kop1VpPlus" HeaderText="WV-Plus">100 <ItemStyle Width="40px" HorizontalAlign="Center"></ItemStyle>101 <ItemTemplate>102 <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Bind("Kop1VpPlus")%>' Enabled="false" />103 </ItemTemplate>104 </asp:TemplateField>105 <asp:TemplateField SortExpression="Kop1AanvraagNaam" HeaderText="Aanvrager">106 <ItemStyle Width="95px" HorizontalAlign="Left"></ItemStyle>107 <ItemTemplate>108 <asp:Label ID="Label2" runat="server" Text='<%# Bind("Kop1AanvraagNaam")%>'></asp:Label>109 </ItemTemplate>110 </asp:TemplateField>111 <asp:TemplateField SortExpression="Kop1AanvraagDatum" HeaderText="Aanvraag-datum">112 <ItemStyle Width="80px" HorizontalAlign="Left"></ItemStyle>113 <ItemTemplate>114 <asp:Label ID="Label3" runat="server" Text='<%# Bind("Kop1AanvraagDatum", "{0:d}")%>'></asp:Label><br />115 </ItemTemplate>116 </asp:TemplateField>117 <asp:TemplateField SortExpression="Kop1AlgLocatie" HeaderText="Locatie">118 <ItemStyle Width="130px" HorizontalAlign="Left"></ItemStyle>119 <ItemTemplate>120 <asp:Label ID="Label4" runat="server" Text='<%# Bind("Kop1AlgLocatie")%>'></asp:Label>121 </ItemTemplate>122 </asp:TemplateField>123 <asp:TemplateField HeaderText="Werk / Reden">124 <ItemStyle Height="60px" Wrap="True" HorizontalAlign="Left" VerticalAlign="Top"></ItemStyle>125 <ItemTemplate>126 <asp:Panel ID="Panel2" runat="server" Height="60px" ScrollBars="Vertical">127 <asp:Label ID="Label5" runat="server" Height="60px" Text='<%# Bind("Kop2WerkReden")%>'></asp:Label>128 </asp:Panel>129 </ItemTemplate>130 </asp:TemplateField>131 <asp:TemplateField SortExpression="Kop1UitvAanvangsdatum1" HeaderText="Aanvangs-datum">132 <ItemStyle Width="80px" HorizontalAlign="Left"></ItemStyle>133 <ItemTemplate>134 <asp:Label ID="Label1" runat="server" Text='<%# Eval("Kop1UitvAanvangsdatum1", "{0:d}")%>' ToolTip="aanvangsdatum"></asp:Label> <br />135 <asp:Label ID="Label7" runat="server" Style="font-size: 8pt; color: blue; font-style: italic;136 background-color: yellow" Text='<%# Eval("Kop1UitvEinddatum1", "{0:d}")%>' ToolTip="einddatum"></asp:Label>137 </ItemTemplate>138 </asp:TemplateField>139 <asp:TemplateField SortExpression="status" HeaderText="Status">140 <ItemStyle Width="40px" HorizontalAlign="Center"></ItemStyle>141 <ItemTemplate>142 <asp:Label ID="Label6" runat="server" Text='<%# Bind("status")%>'></asp:Label>143 </ItemTemplate>144 </asp:TemplateField>145 <asp:TemplateField Visible="False" ShowHeader="False">146 <ItemStyle Width="35px" HorizontalAlign="Left"></ItemStyle>147 <ItemTemplate>148 <asp:Button ID="Button3" runat="server" Style="background-attachment: fixed; background-color: transparent;149 background-image: url(http://eb-service/WV/MemberPaginas/images/delete.gif); background-repeat:no-repeat ; border-top-width: thin; border-left-width: thin; border-left-color: moccasin; border-bottom-width: thin; border-bottom-color: moccasin; border-top-color: moccasin; border-right-width: thin; border-right-color: moccasin;"150 Width="32px" tooltip="Verwijder WV (definitief!!!!!)" CommandArgument='<%# eval("Kop1AlgVpNummer")%>' Height="30px" OnCommand="Button3_Command" BorderColor="#FFE0C0" BorderStyle="None" />151 <ajaxToolkit:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server" TargetControlID="Button3" ConfirmText="Zeker weten?"></ajaxToolkit:ConfirmButtonExtender>152 </ItemTemplate>153 </asp:TemplateField>154 </Columns>155156 <RowStyle Font-Size="11pt" Font-Overline="False"></RowStyle>157 <SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite"></SelectedRowStyle>158 <PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" Font-Size="10pt" Font-Bold="True" Font-Strikeout="False"></PagerStyle>159 <HeaderStyle BackColor="Tan" Font-Size="12pt" Font-Overline="False" Font-Bold="True"></HeaderStyle>160 <AlternatingRowStyle BackColor="Moccasin" Font-Size="11pt" Font-Strikeout="False"></AlternatingRowStyle>161 </asp:GridView>162 <asp:Button style="LEFT: 950px; CURSOR: hand; POSITION: absolute; TOP: 68px" id="Button5" runat="server" Text="delete" Font-Size="8pt" Font-Bold="True" BorderStyle="Ridge" ForeColor="#0000C0" BackColor="#FFC080" ToolTip="laat kolom 'verwijderen' zien (alleen beheerders)" Height="19px" BorderColor="#FF8000"></asp:Button>163164 <asp:Panel id="Panel1" runat="server" Width="1000px" HorizontalAlign="Center" Direction="LeftToRight">165 <asp:SqlDataSource id="SqlDataSource2" runat="server" SelectCommand="SELECT [Kop1AlgVpnummer] FROM [DATA] ORDER BY [Kop1AlgVpnummer] DESC" ConnectionString="<%$ ConnectionStrings:WV-ConnectionString%>">166 </asp:SqlDataSource>167 <asp:SqlDataSource id="SqlDataSource3" runat="server" SelectCommand="SELECT [achternaam], [asp_naam] FROM [emailadressen] WHERE ([achternaam] IS NOT NULL) ORDER BY [achternaam]" ConnectionString="<%$ ConnectionStrings:WV-ConnectionString%>">168 </asp:SqlDataSource>169170 <asp:UpdateProgress id="UpdateProgress1" runat="server">171 <ProgressTemplate>172 <div style="left: 280px; position: absolute; top: 400px">173 <img alt="" src="../MemberPaginas/images/progressbar_long_green.gif" height="40px" width="500px" />174 </div>175 </ProgressTemplate>176 </asp:UpdateProgress>177178 <ajaxToolkit:TextBoxWatermarkExtender id="TextBoxWatermarkExtender1" watermarkText="Filter: werk/reden" runat="server" WatermarkCssClass="watermerk" TargetControlID="RedenTextBox"></ajaxToolkit:TextBoxWatermarkExtender>179 <ajaxToolkit:TextBoxWatermarkExtender id="TextBoxWatermarkExtender2" watermarkText="Filter: locatie" runat="server" WatermarkCssClass="watermerk" TargetControlID="LokatieTextBox"></ajaxToolkit:TextBoxWatermarkExtender>180 <asp:Panel style="BORDER-RIGHT: green thin solid; BORDER-TOP: green thin solid; DISPLAY: none; BORDER-LEFT: green thin solid; COLOR: blue; BORDER-BOTTOM: green thin solid; BACKGROUND-COLOR: yellow; TEXT-ALIGN: left; backcolor: gray; forecolor: blue" id="Panel10" runat="server" Font-Size="10pt" Width="350px"><P><SPAN style="TEXT-DECORATION: underline">Met dit filter kunt u het overzicht filteren aan de hand van de gewenste status:</SPAN></P>0: aangevraagd<BR />1: niet akkoord<BR />2: akkoord, nog niet actief<BR />3: actief<BR />4: verlopen<BR />5: beeindigd<BR /><BR />Het is mogelijk om alleen te filteren op WV's met een bepaalde status (=), of op WV's met een bepaalde status en kleiner (<=).<BR /><BR />Dit filter staat standaard op alleen actieve WV's ingesteld (status = 3).<BR /><BR />Let op, dit filter werkt samen met de andere filters!<BR /><BR /><DIV style="TEXT-ALIGN: center"><asp:Button id="OkButton" runat="server" Text="OK"></asp:Button></DIV></asp:Panel>181 <asp:Panel style="BORDER-RIGHT: green thin solid; BORDER-TOP: green thin solid; DISPLAY: none; BORDER-LEFT: green thin solid; COLOR: blue; BORDER-BOTTOM: green thin solid; BACKGROUND-COLOR: yellow; TEXT-ALIGN: left; backcolor: gray; forecolor: blue" id="Panel11" runat="server" Font-Size="10pt" Width="350px"><P><SPAN style="TEXT-DECORATION: underline">Met dit filter kunt u het overzicht filteren op aanvrager.</SPAN></P>Selecteer een naam in de keuzelijst en het overzicht geeft alle WV's weer van die persoon.<BR /><BR />Let op, dit filter werkt samen met de andere filters!<BR /><BR /><DIV style="TEXT-ALIGN: center"><asp:Button id="OkButton2" runat="server" Text="OK"></asp:Button></DIV></asp:Panel>182 <asp:Panel style="BORDER-RIGHT: green thin solid; BORDER-TOP: green thin solid; DISPLAY: none; BORDER-LEFT: green thin solid; COLOR: blue; BORDER-BOTTOM: green thin solid; BACKGROUND-COLOR: yellow; TEXT-ALIGN: left; backcolor: gray; forecolor: blue" id="Panel12" runat="server" Font-Size="10pt" Width="350px"><P><SPAN style="TEXT-DECORATION: underline">Met dit filter kunt u direct een WV selecteren.</SPAN></P>Selecteer een WV in de keuzelijst (alle WV's) en het overzicht geeft alleen die WV weer.<BR /><BR />Let op, dit filter werkt niet samen met de andere filters!<BR /><BR /><DIV style="TEXT-ALIGN: center"><asp:Button id="OkButton3" runat="server" Text="OK"></asp:Button></DIV></asp:Panel>183 <asp:Panel style="BORDER-RIGHT: green thin solid; BORDER-TOP: green thin solid; DISPLAY: none; BORDER-LEFT: green thin solid; COLOR: blue; BORDER-BOTTOM: green thin solid; BACKGROUND-COLOR: yellow; TEXT-ALIGN: left; backcolor: gray; forecolor: blue" id="Panel13" runat="server" Font-Size="10pt" Width="350px"><P><SPAN style="TEXT-DECORATION: underline">Met dit filter kunt u het overzicht filteren op jaar.</SPAN></P>Selecteer een jaar in de keuzelijst en het overzicht geeft alleen WV's weer die op dat jaar betrekking hebben.<BR /><BR />Dit filter staat standaard op het huidige jaar.<BR /><BR />Let op, dit filter werkt samen met de andere filters!<BR /><BR /><DIV style="TEXT-ALIGN: center"><asp:Button id="OkButton4" runat="server" Text="OK"></asp:Button></DIV></asp:Panel>184 <asp:Panel style="BORDER-RIGHT: green thin solid; BORDER-TOP: green thin solid; DISPLAY: none; BORDER-LEFT: green thin solid; COLOR: blue; BORDER-BOTTOM: green thin solid; BACKGROUND-COLOR: yellow; TEXT-ALIGN: left; backcolor: gray; forecolor: blue" id="Panel14" runat="server" Font-Size="10pt" Width="350px"><P><SPAN style="TEXT-DECORATION: underline">Exporteer hiermee het overzicht naar PDF.</SPAN></P>Met deze knop kunt u het huidige overzicht naar een zgn. PDF-bestand exporteren. <BR /><BR /><DIV style="TEXT-ALIGN: center"><asp:Button id="OkButton5" runat="server" Text="OK"></asp:Button></DIV></asp:Panel>185 <asp:Panel style="BORDER-RIGHT: green thin solid; BORDER-TOP: green thin solid; DISPLAY: none; BORDER-LEFT: green thin solid; COLOR: blue; BORDER-BOTTOM: green thin solid; BACKGROUND-COLOR: yellow; TEXT-ALIGN: left; backcolor: gray; forecolor: blue" id="Panel15" runat="server" Font-Size="10pt" Width="350px"><P><SPAN style="TEXT-DECORATION: underline">Voer zoekopdracht uit.</SPAN></P>Met deze knop kunt u het overzicht filteren met de gewenste zoekopties.<BR /><BR />Er zijn meerdere zoekopties aanwezig: de zoekopdracht start automatisch bij het kiezen van een item in keuzelijsten, maar niet bij de tekst-filters (locatie en werk/reden). <BR /><BR />Kies ook deze knop om uw zoekopdracht opnieuw uit te voeren en/of het overzicht te verversen.<BR /><BR /><DIV style="TEXT-ALIGN: center"><asp:Button id="OkButton6" runat="server" Text="OK"></asp:Button></DIV></asp:Panel>186 <ajaxToolkit:ModalPopupExtender id="ModalPopupExtender" runat="server" TargetControlID="Button_help" OkControlID="OkButton" DropShadow="true" BackgroundCssClass="modalBackground" PopupControlID="Panel10"></ajaxToolkit:ModalPopupExtender>187 <ajaxToolkit:ModalPopupExtender id="ModalPopupExtender1" runat="server" TargetControlID="Button_help2" OkControlID="OkButton2" DropShadow="true" BackgroundCssClass="modalBackground" PopupControlID="Panel11"></ajaxToolkit:ModalPopupExtender>188 <ajaxToolkit:ModalPopupExtender id="ModalPopupExtender2" runat="server" TargetControlID="Button_help3" OkControlID="OkButton3" DropShadow="true" BackgroundCssClass="modalBackground" PopupControlID="Panel12"></ajaxToolkit:ModalPopupExtender>189 <ajaxToolkit:ModalPopupExtender id="ModalPopupExtender3" runat="server" TargetControlID="Button_help4" OkControlID="OkButton4" DropShadow="true" BackgroundCssClass="modalBackground" PopupControlID="Panel13"></ajaxToolkit:ModalPopupExtender>190 <ajaxToolkit:ModalPopupExtender id="ModalPopupExtender4" runat="server" TargetControlID="Button_help5" OkControlID="OkButton5" DropShadow="true" BackgroundCssClass="modalBackground" PopupControlID="Panel14"></ajaxToolkit:ModalPopupExtender>191 <ajaxToolkit:ModalPopupExtender id="ModalPopupExtender5" runat="server" TargetControlID="Button_help6" OkControlID="OkButton6" DropShadow="true" BackgroundCssClass="modalBackground" PopupControlID="Panel15"></ajaxToolkit:ModalPopupExtender>192 <asp:Label id="naamLabel" runat="server" Font-Size="6pt" Visible="False"></asp:Label>193 </asp:Panel>194 </ContentTemplate>195 </asp:UpdatePanel>196 </div>197</asp:Content>

Are you sure you need to use the Confirm button? If all you want is for a confirm box to popup with a message, you can try just using the OnClientClick of the button itself. It would look like

onclientclick="return confirm('Zeker weten?')"

so your button will be...

<asp:Button ID="Button3" runat="server" Style="background-attachment: fixed; background-color: transparent;
background-image: url(http://blabla.gif); background-repeat:no-repeat ; border-top-width: thin; border-left-width: thin; border-left-color: moccasin; border-bottom-width: thin; border-bottom-color: moccasin; border-top-color: moccasin; border-right-width: thin; border-right-color: moccasin;"
Width="32px" tooltip="Verwijder WV (definitief!!!!!)" CommandArgument='<%# eval("Kop1AlgVpNummer")%>' Height="30px" OnCommand="Button3_Command" BorderColor="#FFE0C0" BorderStyle="None"onclientclick="return confirm('Zeker weten?')" />

I do this all the time in gridview delete buttons. It works just like the confirm button.

-Alan


Good tip, I'll try this tomorrow. Maybe i didn't think of this because of my limited knowledge of javascript...

This works fine, the error is gone.

You could, however, ask yourself why the error is produced...

ConfirmButtonExtender in DataView TemplateField - only works once!

I have a TemplateField in my DataView that is used to hold a link button to remove the item from the list. I have added a ConfirmButtonExtender to the template as well, and it works the first time I click the linkbutton, and if I click Cancel it will keep poping up when I click any of the linkbuttons again, but if I click OK to remove the item, the next time I click on a link button the ConfirmButtonExtender doesn't pop up to confirm. Below is the code where it is implemented.

<asp:TemplateFieldHeaderText="">

<ItemTemplate><asp:LinkButtonID="lnkRemoveIngredient"runat="server"Text="Remove"CommandName="Remove"CausesValidation="false"></asp:LinkButton><ajaxToolkit:ConfirmButtonExtenderID="cbelnkRemoveIngredient"runat="server"TargetControlID="lnkRemoveIngredient"ConfirmText="Are you sure?"/></ItemTemplate>

Just wondering if this is a known bug or if there is a way around this!

It always seems like I reply to my own posts, but I have approached this problem differently. Instead of using the ConfirmButtonExtender I have added a OnClientClick to the above mentioned linkbutton and the functionality works as desired.

<ItemTemplate>

<asp:LinkButtonID="lnkRemoveIngredient"runat="server"Text="Remove"CommandName="Remove"CausesValidation="false"OnClientClick="return confirm('Are you sure?');"></asp:LinkButton></ItemTemplate>

Easy enough... but still interested in why the ConfirmButtonExtender acts up in this scenario


Sounds kind of like:http://forums.asp.net/thread/1441672.aspx?

Confirmbuttonextender how to stop confirm if validation fails

I am trying to use the confirmbuttonextender, but I only want to show the confirm message if some validation passes. I have a button that calls a javascript function to perform some validation. If validation fails the javascript returns false and would stop the button from submiting. I tried setting the ConfirmOnFormSubmit=true, but when I do this the javascript function doesn't seem to be called. When it is false the confirm message appears, then I click OK, then the javascript is called, but the button still submits even thought the function returned false. Any help would be appreciated, I haven't found any working example.

Thanks,
Matt

My code:

<ajaxToolkit:ConfirmButtonExtender ID="ConfirmButtonExtender1" TargetControlID="btnDelete" runat="server"
ConfirmText="Are you sure you want to delete?" ConfirmOnFormSubmit=true ></ajaxToolkit:ConfirmButtonExtender>
<asp:Button ID="btnDelete" runat="server" Text="Delete" OnClientClick="DeleteEquipFunction();" />


<script type="text/javascript">
function DeleteEquipFunction()
{
//some validation
return false;
}
</script>

I think, if this case you should not use ConfirmButtonExtender, because AJAX creates a function on init event of page, which is then binded to command button.

Can you change your code like this.

<asp:Button ID="btnDelete" runat="server" Text="Delete" OnClientClick="return DeleteEquipFunction();" />

<script type="text/javascript">
function DeleteEquipFunction()
{
//some validation
if(validated) //validated is true
{
return confirm("Are you sure you want to delete?");
}
return false;
}
</script>


Thanks Ritesh.

I wound up following your suggestion and it works good.

I thought the ConfirmOnFormSubmit property was added to the confirmbutton so the confirm would not as the last action before server submission, but it seems to fire before onClientClick, and therefore you can't seem to stop it. I love the Ajax toolkit, but it seems there are some obscure properties of these controls that are not clearly defined on Microsofts website or any book I have found.

confirmbuttonextender error

I have a page with a user control in it. The user control has a 'delete' button which has a confirmbuttonextender attached to it.

I keep getting this error on the page:

[HttpException (0x80004005): The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).]
System.Web.UI.ControlCollection.Add(Control child) +233
Microsoft.AtlasControlExtender.ScriptControlWrapper.Page_PreRenderComplete(Object sender, EventArgs e) +110
System.EventHandler.Invoke(Object sender, EventArgs e) +0
System.Web.UI.Page.OnPreRenderComplete(EventArgs e) +75
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6198

My user control has code blocks to allow dynamically setting of css classes which is required.

Regards,

Andy.

Hi Andy,

Could you provide more information on the problem? The best would be a complete code sample demonstrating the problem you're having. I'm not able to figure out what's going on with just the above.

Thanks,
Ted

Hi Ted,

I have put the required code on our web server at:

http://www.apex-networks.com/files/UserControls.zip

They are all ascx files, and are used in the following heirarchy:

UserMaint.ascx contains one SiteApplicationGridViewCollection.ascx which dynamically creates as many SiteApplicationGridView.ascx as required.

At the moment there is no ConfirmButtonExtender on the delete button in UserMaint.ascx but if you add one you get the error.

Hope this helps.

Andy.

Confirmbuttonextender doesnt work with button with usesubmitbehavior=false

Just more of a warning, if you use a standard button with a confirmbuttonextender and you have the usesubmitbehavior property set to false, the button will still cause the postback even though the messagebox shows to confirm the action. The postback does not wait for the messagebox to be dismissed.

Hi Jrod111,

Yes, if the UseSubmitBehavior="false" , it will send a postback no matter which button you choose. Let's find why.

When UseSubmitBehavior="true" (or not setted), the Button will generate these html code on the client page:

<input type="submit" name="Button" value="Click Me" id="Button" />

But when UseSubmitBehavior="false", the generated html code just like this:

<input type="button" name="Button" value="Click Me" onclick="javascript:__doPostBack('Button','')" id="Button" />

So that's the reason.

Best regards,

Jonathan


Im aware of how the usesubmitbehavior uses javascript, but the confirmbuttonextender attaches to the onclick event. Im guessing its handler fires after the _doPostBack() call, so it never gets intercepted. Maybe there is a tweak you can do to the extender to get its to intercept the onclick first and cancel it if necessary.

ConfirmButtonExtender does not validate prior to

Hi

I've got a scenario where we're using ConfirmButtonExtender on a button which needs to fire client-side validation prior to displaying the confirmation dialog (we're actually using a ModalPopExtender but have tried without). What's happening is that the confirmation dialog is showing but client-side validation is not firing until the user clicks OK in the popup. I've set ConfirmOnFormSubmit to True but it's not having the desired effect.

Another strange thing is that our ValidationSummary has ShowMessageBox enabled, but the popup that this normally shows is no longer being displayed, only the "*" next to each field on the form is. We're using an UpdatePanel on the page with all the above controls within it. The event handler for the confirm button click (the button assigned to ConfirmButtonExtender.TargetControlID) is calling Page.Validate and testing Page.IsValid during the asynch postback.

I suspect that I'm not quite using this combination of controls in the correct manner so any pointers most gratefully received.

Thanks

Ben

I've also had problems with this control when used on a button in a gridview. I know there was bug with it, just wondered if its been fixed.

My Page directives:

EnableEventValidation="false"AutoEventWireup="false"

<asp:GridViewID="dgDiets"runat="server"DataKeyNames="Pathway group code,Pathway type code"AutoGenerateColumns="False">

<Columns>

<asp:BoundFieldDataField="Pathway group code"HeaderText="Pathway group code"Visible="false"/>

<asp:BoundFieldDataField="Pathway type code"HeaderText="Pathway type code" />

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

<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="btnDelete" CommandArgument="<%# Container.DataItemIndex %>" CommandName="DeleteRow" runat="server" Text="Delete" />
<cc1:ConfirmButtonExtender ID="ConfirmBtExt1"
runat="server" TargetControlID="btnDelete"
ConfirmText="Are you sure about deleting this record?" />
</ItemTemplate>
</asp:TemplateField>

</Columns>

<asp:GridView>

The following method should, but is not called when user clicks on ok popup:

Protected Sub dgDiets_OnRowCommand(ByVal etc, e as Sys.Web.UI.Webctrls.GridViewCommandEventArgs) Handles dgDiets.RowCommand

I'm sure this works on my home PC, but not at my work PC. However the code is identical. Anybody ever resolve this?

Thanks


Hi Egdif,

Egdif:

I've got a scenario where we're using ConfirmButtonExtender on a button which needs to fire client-side validation prior to displaying the confirmation dialog (we're actually using a ModalPopExtender but have tried without). What's happening is that the confirmation dialog is showing but client-side validation is not firing until the user clicks OK in the popup. I've set ConfirmOnFormSubmit to True but it's not having the desired effect.

Yes , the ConfirmButtonExtender will be shown when the associated Button is clicked. And the form is not going to be posted unless we click the ok button.Validators only work when the post is posting. So that's the problem.

Egdif:

Another strange thing is that our ValidationSummary has ShowMessageBox enabled, but the popup that this normally shows is no longer being displayed, only the "*" next to each field on the form is. We're using an UpdatePanel on the page with all the above controls within it. The event handler for the confirm button click (the button assigned to ConfirmButtonExtender.TargetControlID) is calling Page.Validate and testing Page.IsValid during the asynch postback.

I don't think you need to display another alert window. However, if you want to get the solution for your situation, we really need your source code.

I hope this help.

Best regards,

Jonathan

ConfirmButtonExtender display

i have a "ConfirmButtonExtender" and a save button and the save button wire to "ConfirmButtonExtender" and when i click on save button i get the confirmation which is great.

this.ConfirmButtonExtender1.ConfirmText ="Are you sure?";

but the questin i have is:

is there a way to disable the confirmbuttonextender for certain roles?

what i mean is, i have two roles (admin, users) if the user click on save button i want to display "are you sure" and if the admin clicks i dont want to display any confirmation window.

is that possible ?

thanks

i fixed!

ConfirmButtonExtender Change Button Text

I want to display the button text in Spanish, ie "Borrar" and "Cancelar" instead of "Ok" and "Cancel". How do I achieve this?.

Regards

Peeyush

hello

you can't change the alert buttns text ...

its the same as the browse button of file upload ,

the text depends on the language settings on the client browser .


The sample website at

http://www.asp.net/AJAX/AjaxControlToolkit/Samples/Walkthrough/OtherNeatStuff.aspx

says that strings displayed in the browser can be localized.

Can this help?


this can't be used for localizing the text of the alert buttons.

ConfirmButtonExtender and Validation

I am using theConfirmButtonExtender on a button that has CauseValidation=true.

The button's confirmation alert pops-up even when the page is (not) valid, so the user sees it every time they do not fill out a control properly and submit.

Am I missing a setting or was this extender written regarless of validation controls and page validaty?

Alternatives?

Hi Jjmonty,

My understanding of your issue is that you want to show the ConfirmButtonExtender based on the page validation. If I have misunderstood, please feel free to let me know.

It is a design pattern rather than your code problem. To achieve what you want , we can set the ConfirmButtonExtender's TargetControl to a hidden Button. When we click on the fake Button , it will call a javascript function. The javascript function will first validate the inputs them fire to show the ConfirmButtonExtender . Here is the test sample.

<%@. Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"></script><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"> </asp:ScriptManager> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator> <ajaxToolkit:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server" ConfirmText="Are you sure to submit?"TargetControlID="Button1"> </ajaxToolkit:ConfirmButtonExtender> <div style="display:none"> <asp:Button ID="Button1" runat="server" Text="Button" /> </div><input id="btnFake" type="button" value="Submit" onclick="toSubmitForm()" /> <script language="javascript"> function toSubmitForm(){if(typeof(Page_ClientValidate)=='function'){ if(Page_ClientValidate()) { $get("<%=Button1.ClientID%>").click(); } } } </script> </form></body></html>

Best regards,

Jonathan

ConfirmButtonExtender

In ConfirmButtonExtender, How can i Find Which Button Is Press OK button OR Cancel Button In .cs File

By:

OZA

if the user selects OK then the page will postback and you will exectue your code behind. If the user cancles the action then the page will not postback and you will not need to process the action. So you should not really know if the user pressed the button or not.

Confirmbutton Question

I put a ConfirmButton extender for a button. This button is a submit button which is put in the last step of Wizard. The wizard has validations.

My problem is the ConfirmButton dialog doesn't pop up before the validation logic kicks in.

Any clue?

Try to set UseSubmitBehaviour property of button

For additional information

Validation controls, which includes theBaseCompareValidator,BaseValidator,CompareValidator,CustomValidator,RangeValidator,RegularExpressionValidator,RequiredFieldValidator, andValidationSummary control are not compatible with UpdatePanel

http://weblogs.asp.net/scottgu/archive/2007/01/25/links-to-asp-net-ajax-1-0-resources-and-answers-to-some-common-questions.aspx

Download compatible version of validators from here

http://blogs.msdn.com/mattgi/archive/2007/01/23/asp-net-ajax-validators.aspx

Saturday, March 24, 2012

ConfirmButton & Gridview Autogenerated delete button

Any way to tie the confirmbutton control to the GridView to prompt on the delete button?

The only way to currently do this is to turn your delete column into a template column and then add the extender in there with the button:

<TemplateColumn><ItemTemplate> <asp:LinkButton id="delete" runat="server" CommandName="Delete" Text="Delete"/> <atlasToolkit:ConfirmButtonExtender ID="cbe" runat="server> <atlasToolkit:ConfirmButtonExtenderProperties TargetControlID="delete" ... /> </></ItemTemplate></TemplateColumn>

Since TemplateColumn is normally associated with a DataGrid, does this also work for the TemplateField associated with the GridView? I am getting errors when I try to execute this within the TemplateField: "Assertion Failed: unrecognized tag atlascontroltoolkit:confirmbuttonbehavior". Is there anything special I need to do to use this within a GRIDVIEW?

ConfirmButton - Is it possible to control the button text in the pop-up?

Does anyone know if it is possible to control the button text in the pop-up? I would like to set the button text according to multi-language settings for the application.

Thanks,

Dave

Nop.. you can not control the text of the button in the popup. Since it depends on the client's browser language selection. If you need such customized popup try window.shomodalDialog or window.createPopup(); and put your own buttons.


Sounds like a perfect place to use the modalpopup extender to me!

Jason

Confirm GridView row delete with ModalPopup

Hi,

I have a GridView with a delete Button on each line, to delete that row. This works fine usingCommandName="Delete" propertyon the button and theRowDeleting Event on the GridView.

What I want is to use the ModalPopup to make a delete confirmation, but, I can't put this to work. The RowDeleting Event doen's work anymore.

What should I do?

This is the code:

<ItemTemplate> <asp:ImageButton ID="ibDelete" runat="server" CausesValidation="False" CommandName="Delete" ImageUrl="../../UserFiles/Images/ico_del.gif" ToolTip="delete row"/> <asp:Panel ID="pnlPopUp" runat="server" Style="display: none" CssClass="modalPopup"> <asp:Panel ID="pnlDragPopUp" runat="server" Style="cursor: move;background-color:#DDDDDD;border:solid 1px Gray;color:Black"> <div> <p>Are you sure you want to delete this item?</p> </div> </asp:Panel> <div> <p style="text-align: center;"> <asp:Button ID="OkButton" runat="server" Text="Yes" /> <asp:Button ID="CancelButton" runat="server" Text="Cancel" /> </p> </div> </asp:Panel> <ajax:ModalPopupExtender ID="ModalPopupExtender" runat="server" TargetControlID="ibDelete" PopupControlID="pnlPopUp" BackgroundCssClass="modalBackground" OkControlID="OkButton" CancelControlID="CancelButton" DropShadow="true" PopupDragHandleControlID="pnlDragPopUp" /> </ItemTemplate>
 The GridView Event:
 
 
Protected Sub MyGridView_RowDeleting(ByVal senderAs Object,ByVal eAs GridViewDeleteEventArgs)Dim myConnetionAs SqlConnection =New SqlConnection(erpConn)Dim delCommandAs SqlCommand = myConnetion.CreateCommand() delCommand.CommandText ="myQuery" delCommand.Parameters.Add("@dotnet.itags.org.Adress", SqlDbType.NVarChar).Value = MyGridView.DataKeys(e.RowIndex).Values(0).ToString() myConnetion.Open() delCommand.ExecuteNonQuery() myConnetion.Close() GetUser()End Sub

Anyone?Crying


Hi Cseven,

Would you please remove theOkControlID="OkButton"

<ajax:ModalPopupExtender ID="ModalPopupExtender" runat="server"
TargetControlID="ibDelete"
PopupControlID="pnlPopUp"
BackgroundCssClass="modalBackground"
OkControlID="OkButton" //remove this item
CancelControlID="CancelButton"
DropShadow="true"
PopupDragHandleControlID="pnlDragPopUp" />

In your case, it won't post back, so that's cause the problem.

By the way, in your case , there are severalModalPopupExtenders and Panels in a page. It is cool but not an efficient way.

I hope this help.

Best regards,

Jonathan


the modalpopupextender takes control of its targetcontrol...so in your case the ibDelete button event, which fires the RowDeleting, is being overridden on the client

you have two options:

1) use the old hidden button hack and show your modalpopup programatically. Place another button right above your modalpopupextender and hide it via css...then set your modalpopupextender targetcontrolid to that button... now in your code-behind inside your gridview_rowcommand event...put a logic statement checking e.commandname ...if it equals "Delete" then call ModalPopupExtender.Show()...

2) create a webmethod that deletes the row manually and call it with the onokscript via the modalpopupextender

Confirm functionality with modalpopup

Hi all,

I have been trying to do the following:
Press the delete button in a grid and show a custum modal popup. My idea was to cut the __dopostback script of the button and paste it on the ok button script of the popup. Like so:

ConfirmationButton.ascx:

<%@dotnet.itags.org. Control Language="C#" AutoEventWireup="true" CodeFile="ConfirmationButton.ascx.cs" Inherits="UserControls_Misc_ConfirmationButton" %>
<asp:Button ID="Confirm" runat="server" Text="Button" UseSubmitBehavior="false" OnClick="Confirm_Click" />

ConfirmationButton.ascx.cs:

protected void Page_Load(object sender, EventArgs e)
{

string dopostback = Page.ClientScript.GetPostBackEventReference(Confirm, "");
if (dopostback.IndexOf("__doPostBack") > -1)
dopostback = dopostback.Replace("__doPostBack", "Confirmation");
else
throw new Exception("No __doPostback found in Confirmation button");
Confirm.Attributes.Add("OnClick", dopostback+";return false;");
JavaScriptGenerate();

}

public void JavaScriptGenerate()
{
if (!Page.ClientScript.IsClientScriptBlockRegistered("Confirmbutton"))
{

StringBuilder sb = new StringBuilder();

sb.Append("<script language=\"javascript\">");
sb.Append("function Confirmation(eventTarget, eventArgument)");
sb.Append("{");
sb.Append("$object('MessageBox')._onOkScript = function(){__doPostBack(' + eventTarget + ',' + eventArgument + ');};");
sb.Append("$object('MessageBox')._show();");
sb.Append("}");
sb.Append("</script>");

Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Confirmbutton", sb.ToString());
}
}

protected void Confirm_Click(object sender, EventArgs e)
{
int a = 0;
}

And my ASPX looks like this:

<%@dotnet.itags.org. Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="TEST_Default" %>

<%@dotnet.itags.org. Register Assembly="AtlasControlToolkit" Namespace="AtlasControlToolkit" TagPrefix="atlasToolkit" %>
<%@dotnet.itags.org. Register src="http://pics.10026.com/?src=../UserControls/Misc/ConfirmationButton.ascx" TagName="ConfirmationButton"
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>
<atlas:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="True">
</atlas:ScriptManager>
<uc1:ConfirmationButton ID="ConfirmationButton1" runat="server" />
</div>
<asp:Panel ID="Panel1" runat="server" CssClass="modalPopup" Style="display: none">
<table cellpadding="0" cellspacing="0" border="0">
<tr style="font-weight: bold; color: white; background-color: dimgray;">
<td>
<asp:Label ID="HeaderLabel" runat="server" Text="Header"></asp:Label></td>
</tr>
<tr>
<td>
<asp:Label ID="MessageLabel" runat="server" Text="Message"></asp:Label></td>
</tr>
<tr>
<td align="right">
<asp:Button ID="OkButton" runat="server" Text="Ok" />
<asp:Button ID="CancelButton" runat="server" Text="Cancel" />
</td>
</tr>
</table>
</asp:Panel>
<atlastoolkit:modalpopupextender id="ModalPopupExtender1" runat="server">
<atlasToolkit:ModalPopupProperties BackgroundCssClass="modalBackground" CancelControlID="CancelButton"
PopupControlID="Panel1" TargetControlID="PopupButton" ID="MessageBox" />
</atlastoolkit:modalpopupextender>
<div style="display: none">
<asp:LinkButton ID="PopupButton" runat="server"></asp:LinkButton>
</div>
</form>
</body>
</html
The code above is just a sample of my code hopefully enough for you guys to understand the problem.

I have gotten as far as showing the popup, but when I press the ok button on the popup, a roundtrip happens and nothing else. Why isn't going to the Confirm_click code?

Maybe this whole appoach is wrong. Hope you can help me

Oez

Hey Oez,

I blogged on how I got this scenario to work recently.
Creating a confirmation using the ModalPopup

Thanks for doing this - great blog post. This is something I've been thinkng about so I've logged asIssue 1369. I think the cleanest way for us to do this is to expose the functionality via ConfirmButton rather than via ModalPopup.

Thanks!


I would like to thank Alan for his great blog. This really pushed me in the right direction. I've used his sample to create the functionality I was after.

Intercept the button postback, show a modal popup and if 'yes' is pressed continue with the postback else do nothing.
Here is my sample code. Create a new atlas web project. On the default page create the following code:


<%@.PageLanguage="C#"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="_default" %>
<%@.RegisterSrc="MessageBox.ascx"TagName="MessageBox"TagPrefix="uc1" %>

<!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>Modal Confirmation</title>
<styletype="text/css">
body {
font:normal10pt/13ptArial,Verdana,Helvetica,sans-serif;
color:#666;
margin:20px;
}

/*Modal Popup*/
.modalBackground {
background-color:#000;
filter:alpha(opacity=80);
opacity:0.8;
}
.modalPopupimg {
border:solid5px#fff;
}
.modalPopup-text {
display:block;
color:#000;
background-color:#fff;
text-align:center;
border:solid2px#000;
padding:10px;
}
.modalPopup-textinput {
width:75px;
}

.feedback
{
color:#00cc00;
font-weight:700;
}
</style>

</head>
<body>
<formid="form1"runat="server">
<atlas:ScriptManagerID="ScriptManager1"runat="server"/>
<h2>Modal Confirmation</h2>
<divclass="demo">
<asp:GridViewID="GridView1"runat="server"AutoGenerateColumns="False"OnRowDataBound="GridView1_RowDataBound">
<Columns>
<asp:TemplateFieldShowHeader="False">
<ItemTemplate>
<asp:ButtonID="DeleteButton"runat="server"Text="Delete"/>
</ItemTemplate>
<AlternatingItemTemplate>
<asp:LinkButtonID="DeleteButton"runat="server">Delete</asp:LinkButton>
</AlternatingItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<uc1:MessageBoxID="MessageBox1"runat="server"/>

</div>
</form>
</body>
</html>

And code behind:

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
publicpartialclass_default : System.Web.UI.Page
{
protectedvoid Page_Load(object sender,EventArgs e)
{
DataTable dt =newDataTable();
for (int i = 0; i <= 5; i++)
{
DataRow row = dt.NewRow();
dt.Rows.Add(row);
}
GridView1.DataSource = dt;
GridView1.DataBind();
}

protectedvoid GridView1_RowDataBound(object sender,GridViewRowEventArgs e)
{
WebControl delete = (WebControl)e.Row.FindControl("DeleteButton");
if (delete !=null)
MessageBox1.ConnectButton(delete);
}
}
Now add a usercontrol called MessageBox to the project.
<%@.ControlLanguage="C#"AutoEventWireup="true"CodeFile="MessageBox.ascx.cs"Inherits="MessageBox" %>
<%@.RegisterAssembly="AtlasControlToolkit"Namespace="AtlasControlToolkit"TagPrefix="atlastoolkit" %>
<asp:PanelID="ConfirmtionPanel"runat="server"CssClass="modalPopup"Style="display: none">
<divclass="modalPopup-text">
Are you sure you want to delete this item?<br/>
<br/>
<asp:ButtonID="YesButton"runat="server"Text="Yes"/>
<asp:ButtonID="NoButton"runat="server"Text="No"/>
</div>
</asp:Panel>
<atlastoolkit:ModalPopupExtenderID="ModalPopupExtender1"runat="server">
<atlastoolkit:ModalPopupPropertiesPopupControlID="ConfirmtionPanel"TargetControlID="FakeButton"
OkControlID="YesButton"OnOkScript="onYes()"CancelControlID="NoButton"OnCancelScript="onNo()"
BackgroundCssClass="modalBackground"ID="msgBox"/>
</atlastoolkit:ModalPopupExtender>
<divstyle="display:none">
<asp:LinkButtonID="FakeButton"runat="server">Fake</asp:LinkButton>
<asp:HiddenFieldID="eventTarget"runat="server"></asp:HiddenField>
<asp:HiddenFieldID="eventArgument"runat="server"></asp:HiddenField>
</div>

And the code behind

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using AtlasControlToolkit;
publicpartialclassMessageBox : System.Web.UI.UserControl
{
privatestring _msgBoxId;

protectedvoid Page_Init(object sender,EventArgs e)
{
//This is so you can add multiple MessageBox usercontrols to a page and the ModalPopupProperties will be unique.
_msgBoxId =this.ClientID +"_" + msgBox.ID;
msgBox.ID = _msgBoxId;
}

protectedvoid Page_Load(object sender,EventArgs e)
{
// Expose the __doPostBack function to programmatically call it from javascript
Page.ClientScript.GetPostBackEventReference(this,String.Empty);
if (!Page.ClientScript.IsClientScriptBlockRegistered("MessageBox"))
Page.ClientScript.RegisterClientScriptBlock(this.GetType(),"MessageBox", GetScript());
}

publicstring GetScript()
{
StringBuilder sb =newStringBuilder();
sb.Append("<script type=\"text/javascript\">");
sb.Append("function onYes() {");
sb.Append("var eventTarget = $('");
sb.Append(eventTarget.ClientID);
sb.Append("').value;");
sb.Append("var eventArgument = $('");
sb.Append(eventArgument.ClientID);
sb.Append("').value;");
sb.Append("var postBack = new Sys.WebForms.PostBackAction();");
sb.Append("postBack.set_target(eventTarget);");
sb.Append("postBack.set_eventArgument(eventArgument);");
sb.Append("postBack.performAction();");
sb.Append("}");
sb.Append(" ");
sb.Append("function onNo() {");
sb.Append("//no postback necessary \n");
sb.Append("} ");
sb.Append("</script>");

return sb.ToString();
}

publicvoid ConnectButton(WebControl Confirm)
{
string dopostback = Page.ClientScript.GetPostBackEventReference(Confirm,"");
if (dopostback.IndexOf("__doPostBack") > -1)
dopostback = dopostback.Replace("__doPostBack","Confirmation").Replace(")",",'" + _msgBoxId +"')");
else
thrownewException("No __doPostback found in Confirmation button");
Confirm.Attributes.Add("OnClick", dopostback +";return false;");
JavaScriptGenerate();
}
privatevoid JavaScriptGenerate()
{
if (!Page.ClientScript.IsClientScriptBlockRegistered("Confirmbutton"))
{
StringBuilder sb =newStringBuilder();
sb.Append("<script language=\"javascript\">");
sb.Append("function Confirmation(eventTarget, eventArgument, msgBoxId)");
sb.Append("{");
sb.Append("$('");
sb.Append(eventTarget.ClientID);
sb.Append("').value=eventTarget;");
sb.Append("$('");
sb.Append(eventArgument.ClientID);
sb.Append("').value=eventArgument;");
sb.Append("$object(msgBoxId)._show();");
sb.Append("}");
sb.Append("</script>");

Page.ClientScript.RegisterClientScriptBlock(this.GetType(),"Confirmbutton", sb.ToString());
}
}
}

Hopes this helps for issue 1369. If you guys have any ideas to improve this code, to make it more flexible or better code, I would love see that...do say it...more comments...I know...

Excellent to hear that my post helped! That's what the forums and tech blogs all about.

Alante,

I'm trying to use your code, and it's working in the single form, but not in the page with MasterPage, i changed the javacode to

postBack.set_target('<%=YesButton.ClientID %>');

it's posting back but it's not calling theYesButton_Click event Should I change also the

postBack.set_eventArgument(''); statement to somethign else? I would really apppreciate your help.


A commenter on my blog posted the solution to your problem FrenchilnLA. He got it to work with the master page by using the full reference to the control id, ie. postBack.set_target('ct100_masterName_ YesButton');


I finally add the following code at Page Load event:

string strEvent = ClientScript.GetPostBackEventReference(YesButton,string.Empty);

YesButton.Attributes.Add(

"onclick", strEvent);

Is it funny that we have to force a bostback to a server control that has an Click event ?

This control extender (modal Popup) should allow to be triggered from Server code, and the yes and no button should post back as well.

Thank you anyway I really appreciated your help.

Confirm Extender + Modal Popup -> Call JavaScript on the load, and exit.

I have a Confirm Extender workign with a modal popup extender.

What I'd "like" to do is when the button that launches both is clicked, to run some client script to populate some fields. This saves me from doing it on the server. however, even using OnCLientClick on the button initiating all of this it doesn't work.

Any thoughts?

Also, when I click the OK button close the modal popup confirm box.. .(say that 10x as fast as you can), it would be better for it to close right away, rather than close when the server is done processing.

Is it possible to run script before it hits the server to make the display:none; again?

Hi RTernier,

RTernier:

What I'd "like" to do is when the button that launches both is clicked, to run some client script to populate some fields. This saves me from doing it on the server. however, even using OnCLientClick on the button initiating all of this it doesn't work.

Here is a workable example which you can compare with yours.

<%@. Page Language="C#" %><%@. Import Namespace="System.Threading" %><!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) { Thread.Sleep(3000); }</script><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Untitled Page</title> <style> .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><%=DateTime.Now.ToString()%> <asp:Button ID="Button1" runat="server" Text="Button" /><ajaxToolkit:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server" TargetControlID="Button1" DisplayModalPopupID="ModalPopupExtender1" > </ajaxToolkit:ConfirmButtonExtender> <asp:Panel ID="Panel1" runat="server" CssClass="modalPopup" Style="display: none"> Are you sure? <asp:Button ID="btnOk" runat="server" Text="Ok" /> <asp:Button ID="btnCancel" runat="server" Text="Cancel" /> </asp:Panel> <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="Button1" PopupControlID="Panel1" CancelControlID="btnCancel" BackgroundCssClass="modalBackground" OkControlID="btnOk"> </ajaxToolkit:ModalPopupExtender> <script type="text/javascript" language="javascript"> function pageLoad(){ $find("<%=ModalPopupExtender1.ClientID%>").add_showing(onMPEShowing); } function onMPEShowing(){ //your javascript code here to add fields or do anything what you want. } </script> </form></body></html>

RTernier:

Also, when I click the OK button close the modal popup confirm box.. .(say that 10x as fast as you can), it would be better for it to close right away, rather than close when the server is done processing.

Is it possible to run script before it hits the server to make the display:none; again?

It will be hidden right after be clicked. Please see my sample

Hope this helps.

Best regards,

Jonathan


I can not say how grateful I am for this solution. Wanted same functionality in my app.

I have 1 question though. Is there any client script reference for methods like add_showing etc. I also wanted to do some client side scripting on modal popup closing ..and i just guessed the function (must be my luck day) add_hiding..which worked beautifully!

However, I would still love a client side script reference for the same. Please advise. Thanks!