I have the following structure in place and need to rebind the lower control (DropDownList)
from the code behind of the MainPage.
x MainPage1 x---- Panel1 (modal popup)
x--------- UpdatePanel (upMailOrStatusAction, on Panel1)
x-------------- RadioButtonList (rblActionLevel, on UpdatePanel)
x-------------- SubForm1 (on Panel1)
x------------------- CustomControl1 (on Subform1)
x------------------------ DropDownList (on CustomControl1)
What would be the correct way to accomplish this?
I added a public method "BindMailActionLookup()" to the control, but how do I call it from the main page? I get "does not exist in the current context"?
Here is the markup of the subform:
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="MailAddSubform.ascx.cs"
Inherits="Company.Solutions.Web.Controls.MailAddSubform" %>
<%# Register TagPrefix="st" TagName="MailActionLookup" Src="~/Controls/StMailActionLookup.ascx" %>
<div class="NinetyNinePercentWide">
<div class="NinetyNinePercentWide EightPixelBottomMargin">
<div class="RowHeader" style="padding-top: 20px;">
<span class="labelfield" >Action:</span>
</div>
<div>
<st:MailActionLookup ID="mailActionLookup" runat="server" />
</div>
</div>
<div class="NinetyNinePercentWide EightPixelBottomMargin" >
<br class="NinetyNinePercentWide" Text=" " />
<div class="RowHeader" >
<span class="labelfield" >Message:</span>
</div>
<div class="TwelvePixelLeftPad" >
<asp:TextBox ID="txtMailActionMessage" runat="server" MaxLength="40" />
</div>
</div>
</div>
Here is the markup for the custom control:
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="StMailActionLookup.ascx.cs" Inherits="Company.Solutions.Web.Controls.StMailActionLookup" %>
<div id="mainControlContainer" style="width:99%; padding:8px;">
<div id="comboContainer" style="float:left; padding-top:12px;padding-left:5px; padding- right:5px; padding-bottom:3px;">
<asp:UpdatePanel runat="server" ID="mailActionUpdater">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="chkForms" EventName="CheckedChanged" />
<asp:AsyncPostBackTrigger ControlID="chkRequested" EventName="CheckedChanged" />
<asp:AsyncPostBackTrigger ControlID="chkOther" EventName="CheckedChanged" />
</Triggers>
<ContentTemplate>
<asp:DropDownList runat="server" ID="ddlLookup" width="240px" ondatabound="ddlLookup_DataBound1" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
<div id="filterContainer" style="text-align:left;padding-left:6px;width:275px">
<fieldset style="width:260px;">
<legend>Filters</legend>
<asp:CheckBox ID="chkForms" runat="server" Text="Forms" AutoPostBack="true" />
<asp:CheckBox ID="chkRequested" runat="server" Text="Requested Info" AutoPostBack="true" />
<asp:CheckBox ID="chkOther" runat="server" Text="Other" AutoPostBack="true" />
</fieldset>
</div>
</div>
And here is part of the code behind where I added the public method:
namespace Company.Solutions.Web.Controls
{
public partial class StMailActionLookup : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
BindForm();
}
public void BindMailActionLookup()
{
BindForm();
}
protected void BindForm()
{
GetActionLevel();
IEnumerable actions = GetClaimMailActions(GetFilter());
ddlLookup.DataSource = actions;
ddlLookup.DataTextField = "CodeAndDescription";
ddlLookup.DataValueField = "ActionCd";
ddlLookup.DataBind();
}
}
}
You shouldn't be exposing the internals of CustomControl1 to a consumer, so the most correct way would be to expose a public method (maybe call it "ResetDropDowns") on your CustomControl1 that the main page could call into.
CustomControl1 knows about it's own dropdowns, so it can easily find and rebind the control when someone calls the method.
Ok, we have a solution thanks to "womp's" suggestions and one of my co-workers.
Just keep nesting the public calls in a chain:
This in the main Claim Info code behind:
// Rebind the action code drop down to restrict to base level
mailAddSubform.BindMailActionLookup();
Then this in the subform code behind:
public void BindMailActionLookup()
{
mailActionLookup.BindMailActionLookup();
}
And finally, this in the lookup control:
public void BindMailActionLookup()
{
BindForm();
}
Related
I have a user control within a child page within a master page in which I need a panel to be displayed according to a check box's checked status.
I could use jQuery to accomplish this, but I need Ajax. Now if you are familiar with DX CallbackPanel you know that this control is just like the ASP.NET update panel.
When I check my check box I call a JavaScript function that calls the CallbackPanel.PerformCallback() function, and this function does what it does.
This is my user control:
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="dx_auto_saxs_sales.ascx.cs" Inherits="bime.shokri.v1._0._1.Forms.dx_auto_saxs_sales" %>
<%# Register Assembly="DevExpress.Web.v15.2, Version=15.2.10.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web" TagPrefix="dx" %>
<script type="text/javascript">
var CallbackInQue = false;
function CheckBoxBimeSalQabl_CheckedChanged(s,e)
{
if (ASPxCallbackPanel.InCallback())
CallbackInQue = true;
else
ASPxCallbackPanel.PerformCallback();
}
function OnEndCallback(s,e)
{
if(CallbackInQue)
{
ASPxCallbackPanel.PerformCallback();
CallbackInQue = false;
}
}
</script>
<dx:ASPxCheckBox ID="ASPxCheckBox2" runat="server" Theme="MetropolisBlue" Text="بیمه نامه سال قبل دارد" Font-Names="yekan" CheckState="Unchecked" ClientInstanceName="ChechBoxBimeSalQabl">
<ClientSideEvents CheckedChanged="CheckBoxBimeSalQabl_CheckedChanged" />
</dx:ASPxCheckBox>
<dx:ASPxCallbackPanel ID="ASPxCallbackPanel" runat="server" ClientInstanceName="ASPxCallbackPanel">
<SettingsLoadingPanel Text="صبر کنید…" />
<ClientSideEvents EndCallback="OnEndCallback" />
<PanelCollection>
<dx:PanelContent runat="server">
<asp:Panel runat="server" ID="pnl_formerBimeName">
<div class="three fields">
<div class="field">
<label>تعداد سال های تخفیف <span style="color: #c66050">●</span></label>
<dx:ASPxComboBox ID="ASPxComboBox7" runat="server" ValueType="System.String" BackColor="#efefef" CssClass="round-corner-control" Theme="MetropolisBlue" Font-Names="yekan" NullText="انتخاب کنید" Width="90%">
<Items>
<dx:ListEditItem Text="1 سال عدم خسارت" Value="0" />
</Items>
</dx:ASPxComboBox>
</div>
</div>
</asp:Panel>
</dx:PanelContent>
</PanelCollection>
</dx:ASPxCallbackPanel>
The purpose is to display Panel(pnl_formerBimeName) when CheckBox is checked.
Now this is my Page_Load(sender,object) method which is called asynchronous when Checkbox is checked:
protected void Page_Load(object sender, EventArgs e)
{
pnl_formerBimeName.Visible = ASPxCheckBox2.Checked;
}
Everything is OK until I deploy my website to my server. After that when I check the checkbox the "Loading..." the text appears and takes forever to complete. I really don't know why.
Just in case you wonder about this problem in action, I give you the mentioned page here.
In my ASP.NET .NET 3.5 I have custom control that has UpdatePanel inside.
In that update panel I Wizard control with 7 steps.
In second step I want to upload attachments using AsyncFileUpload.
In my scenario user can add multiple files and they will show inside grid, so after upload he can add comments to them.
Everything works file if I have AsyncFileUpload in Step that is visible at beginning, UploadedComplete event is fired correctly, but when I start from different step I can't get that Upload to work.
I was thinking about using iframe, but I would like to avoid it because I need to have 5 upload components in different Steps.
Is it possible to get that AsyncFileUpload to work in Wizard?
My code is standard, nothing magical at moment:
ToolkitScriptManager
UpdatePanel
-ContentTemplate
--Wizard
---WizardSteps
----WizardStep 1
----WizardStep 2
-----AsyncFileUpload
----WizardStep 3
----WizardStep 4
-----AsyncFileUpload 1
-----AsyncFileUpload 2
----WizardStep 5
And my simple event handler
protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
{
var fileUpload = (AjaxControlToolkit.AsyncFileUpload)sender;
if (fileUpload.HasFile)
{
string strPath = path + e.FileName;
AsyncFileUpload1.SaveAs(strPath);
}
}
As I wrote before I get that event if I start from Step 2 (ActiveStepIndex=1).
Here is my ascx code:
<%# Control Language="C#" AutoEventWireup="true" CodeFile="PWS_Test.ascx.cs" Inherits="kontrolki_PWS_Test" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Wizard ID="Wizard1" runat="server" ActiveStepIndex="0">
<WizardSteps>
<asp:WizardStep runat="server" title="Step 1">
<asp:Label ID="Label1" runat="server" Text="Questions"></asp:Label>
<br/>
<asp:CheckBox ID="CheckBox1" runat="server" Text="One"/>
<br/>
<asp:CheckBox ID="CheckBox2" runat="server" Text="Two"/>
</asp:WizardStep>
<asp:WizardStep runat="server" title="Step 2">
<asp:Label ID="Label2" runat="server" Text="Choose Your image"></asp:Label>
<br />
<asp:AsyncFileUpload ID="AsyncFileUpload1" runat="server" FailedValidation="False" OnUploadedComplete="AsyncFileUpload1_UploadedComplete" />
</asp:WizardStep>
</WizardSteps>
</asp:Wizard>
</ContentTemplate>
</asp:UpdatePanel>
And here is cs code:
using System;
public partial class kontrolki_PWS_Test : System.Web.UI.UserControl
{
protected const string path = #"c:\temp\";
protected void Page_Load(object sender, EventArgs e)
{
}
protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
{
var fileUpload = (AjaxControlToolkit.AsyncFileUpload)sender;
if (fileUpload.HasFile)
{
string strPath = path + e.FileName;
AsyncFileUpload1.SaveAs(strPath);
}
}
}
This works when I start from step 2.
As a workaround I've created a hidden div in my control just before wizard:
<div style="display: none">
<asp:AsyncFileUpload ID="AsyncFileUpload2" runat="server" />
</div>
and now my upload is working, but I would like normal solution instead of that workaround.
Add the attribute: enctype="multipart/form-data" to your <form> tag.
<form id="form1" runat="server" enctype="multipart/form-data">
...
...
</form>
(Asp.net 4)
I have a blog where i use a repeater to show all the blog-articles and the comments to each blog. I'm trying to change how the users can post comments to the blog. I want to put the comments under each blog in an UpdatePanel, and when they write a comment and click on a save-button, i want to refresh the comments, so their new comment will show. But I'm having difficulties achieving this.
I've added the UpdatePanel in the ItemTemplate of the Repeater, and added the Textboxes and Button for saving the comment. Each UpdatePanel is placed in a with the id of the blog. But I don't know how to create the code for saving the comment for the correct blog-id, and then to refresh that UpdatePanel.
Code:
<asp:Repeater ID="RepeaterBlog" runat="server">
<ItemTemplate>
<article>
<% if (repeaterCounter == 0)
{
Response.Write("<header class=\"firstArticleInBlog\">");
}
else
{
Response.Write("<header class=\"normalArticle\">");
}
%>
<h2><%# Eval("article_header") %> <span class="date">
<time datetime="<%# GetPubDate(Eval("article_date")) %>"><%# FormatDate(Eval("article_date")) %></time></span></h2></header>
<p><%# Eval("article_content") %><p><br />
<div class="comments">
<div class="showhidecomments">
<!--<a class="iframe-comments" data-fancybox-type="iframe" href='WriteComments.aspx?BlogId=<%# DataBinder.Eval(Container, "DataItem.id") %>'>Skriv kommentar</a> | -->
Vis/Skriv kommentarer (<%# CountComments (DataBinder.Eval(Container, "DataItem.id")) %>) | <a href="javascript:void(0);" title="i<%# Eval("id") %>" >Skjul kommentarer</a>
</div>
<section>
<article>
<div id="i<%# Eval("id") %>" style="display: none;">
<asp:UpdatePanel ID="upPanel" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="cmdSaveComment" EventName="Click" />
</Triggers>
<ContentTemplate>
<%# GetComments (DataBinder.Eval(Container, "DataItem.id")) %>
<asp:TextBox ID="txtName" runat="server" />
<asp:TextBox ID="txtComment" runat="server" TextMode="MultiLine" />
<asp:Button ID="cmdSaveComment" runat="server" OnClick="cmdSaveComment_Click" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</article>
</section>
</div>
<% repeaterCounter++; %>
</article>
</ItemTemplate>
</asp:Repeater>
And in the code-behind:
protected void cmdSaveComment_Click(object sender, EventArgs e)
{
//simplified code:
string name = txtName.Text;
string comment = txtComment.Text;
int blogId = (int)(Eval("DataItem.id"));
dataHandler.NewComment(name, comment, blogId);
}
Am i at least close to something here, or am i completely on the wrong track?
You need to use the ItemCommand property for the repeater and the CommandName property for your button.
First declare the event name for the repeater and the button's command name in your aspx. Note the CommandName replaces the OnClick for your button. Also you give the button a command argument, this being the ID for the article record that the comment is for.
<asp:Repeater ID="RepeaterBlog" runat="server" OnItemCommand="RepeaterBlog_ItemCommand">
<asp:Button ID="cmdSaveComment" runat="server" CommandName="SaveComment" CommandArgument='<%# Eval("id")%>' />
Now add this in the code behind
void RepeaterBlog_ItemCommand(Object Sender, RepeaterCommandEventArgs e) {
if(e.CommandName == "SaveComment") {
string name = ((TextBox)e.Item.FindControl("txtName")).Text;
string comment = ((TextBox)e.Item.FindControl("txtComment")).Text;
dataHandler.NewComment(name, comment, e.CommandArgument);
}
}
That should get you started
I'm having a problem hiding one ModalPopupExtender and Showing another within the same server-side call.
My app requires user input on some validating conditions. These conditions are evaluated in sequence and when certain conditions are true it requires a user to verify (click yes or no) via a ModalPopupExtender window. If the user clicks Yes, evaluation should continue and if another condition requires user input it should also open a modal dialog - until all conditions are passed.
I've got no problem if only one of the conditions requires input, but if more than one require input, only the first modal is displayed and I can't figure out why. When tracing the code it's clear that the Hide() on the first popup is hit and the Show() on the second popup is hit, but the second popup never shows up.
I've tried to pull out the relevant code blocks here with extreme simplification. It's a really complex project and I may have missed something but I hope it's enough to describe my problem.
Problematic process flow:
User clicks "Continue" -> DoContinue is called -> set conditions flags -> Show first modal popup -> Return to user
User clicks "Yes" -> calls condition 1 Yes click handler (set handled flag, hide modal popup) -> call DoContinue-> re-evaluate conditions flags -> attempt to show second modal popup -> return to user.
The first popup disappears but the second is never shown.
It's only a problem when Hide() is being called on the first modal in the same request where Show() is being called on the second.
MyContainerControl.ascx:
<%# Control Language="C#" AutoEventWireup="true" Inherits="MyContainerControl" %>
<input Type="Submit"
id="btnContinue"
Name="btnContinue"
Value="Continue"
OnServerClick="Continue_Click"
runat="server"/>
<asp:UpdatePanel
ID="updateCondition1"
runat="server"
ChildrenAsTriggers="false" UpdateMode="Conditional">
<ContentTemplate>
<ajaxToolkit:ModalPopupExtender
ID="modalCondition1"
runat="server"
BehaviorID="dlgCondition1"
TargetControlID="btnFakeInvokeModalCondition1"
PopupControlID="divCondition1"
BackgroundCssClass="modalBackground"
DropShadow="true"
PopupDragHandleControlID="divDragCondition1"
RepositionMode="RepositionOnWindowResize"
CancelControlID="btnCondition1No" />
<input type="button"
id="btnFakeInvokeModalCondition1"
runat="server"
style="display: none" />
<div id="divCondition1"
runat="server"
class="modalPopup">
<custom:Condition1Control id="condition1" runat="server" visible="false" />
<div id="divDragCondition1"></div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel
ID="updateCondition2"
runat="server"
ChildrenAsTriggers="false" UpdateMode="Conditional">
<ContentTemplate>
<ajaxToolkit:ModalPopupExtender
ID="modalCondition2"
runat="server"
BehaviorID="dlgCondition2"
TargetControlID="btnFakeInvokeModalCondition2"
PopupControlID="divCondition2"
BackgroundCssClass="modalBackground"
DropShadow="true"
PopupDragHandleControlID="divDragCondition2"
RepositionMode="RepositionOnWindowResize"
CancelControlID="btnCondition2No" />
<input type="button"
id="btnFakeInvokeModalCondition2"
runat="server"
style="display: none" />
<div id="divCondition2"
runat="server"
class="modalPopup">
<custom:Condition2Control id="condition2" runat="server" visible="false" />
<div id="divDragCondition2"></div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
MyContainerControl.cs:
public class MyContainerControl : System.Web.UI.UserControl
{
protected HtmlInputImage btnContinue;
//Condition1
protected AjaxControlToolkit.ModalPopupExtender modalCondition1;
protected UpdatePanel updateCondition1;
protected HtmlGenericControl divCondition1;
protected Condition1Control condition1;
//Condition2
protected AjaxControlToolkit.ModalPopupExtender modalCondition2;
protected UpdatePanel updateCondition2;
protected HtmlGenericControl divCondition2;
protected Condition2Control condition2;
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
condition1.Condition1RaisedEvent += HandleCondition1Event;
condition2.Condition2RaisedEvent += HandleCondition2Event;
btnContinue.ServerClick += btnContinue_ServerClick;
}
protected void HandleCondition1Event(object sender, Condition1EventArgs e)
{
// use ship to store
ViewState["Condition1Yes"] = true;
ViewState["Condition1Value"] = e.Condition1Value;
modalCondition1.Hide();
DoContinue(sender);
}
protected void HandleCondition2Event(object sender, Condition2EventArgs e)
{
// use ship to store
ViewState["Condition2Yes"] = true;
ViewState["Condition2Value"] = e.Condition2Value;
modalCondition2.Hide();
DoContinue(sender);
}
protected void btnContinue_ServerClick(object sender, EventArgs e)
{
DoContinue(sender);
}
protected void DoContinue(object sender)
{
// test for conditions - just plug to true for demonstration
bool throwCondition1 !(ViewState["Condition1Yes"] == null ? false : (bool)ViewState["Condition1Yes"])
bool throwCondition2 = !(ViewState["Condition2Yes"] == null ? false : (bool)ViewState["Condition2Yes"])
// analyze conditions
if (throwCondition1)
{
var condition1Yes = ViewState["Condition1Yes"] == null ? false : (bool)ViewState["Condition1Yes"];
if (!condition1Yes)
{
divCondition1.Visible = true;
modalCondition1.Show();
return;
}
}
if (throwCondition2)
{
var condition2Yes = ViewState["Condition2Yes"] == null ? false : (bool)ViewState["Condition2Yes"];
if (!condition2Yes)
{
divCondition2.Visible = true;
modalCondition1.Show();
return;
}
}
// do other work
}
}
Condition1UI.ascx - Condition2UI.ascx is very similar:
<%# Control Language="C#" AutoEventWireup="true" Inherits="Condition1Control" %>
<div id="divCondition1Container" runat="server">
<input id="hdnCondition1Value" type="hidden" runat="server" value="<%# this.Condition1Value %>" />
<asp:Panel ID="pnlCondition1UI" runat="server">
<br />
<h2>
Warning!</h2>
<hr />
<br />
<div>
<p>Condition1 has been met.</p>
<br />
<br />
<p>Would you like to continue?</p>
</div>
<br />
<br />
</asp:Panel>
<div>
<table>
<tr>
<td align="center">
<asp:Button ID="btnCondition1Yes" runat="server" class="green" Text="Yes" style="padding: 3px 7px;" OnClick="DoCondition1YesClick" OnClientClick="$find('dlgCondition1').hide();" />
</td>
<td align="center">
<button id="btnCondition1No" class="red">No</button>
</td>
</tr>
</table>
<br />
</div>
<br />
</div>
Condition1Control.cs - Condition2Control.cs is almost identical:
public class Condition1EventArgs : EventArgs
{
public string Condition1Value { get; set; }
}
public class Condition1Control : System.Web.UI.UserControl
{
public HtmlInputHidden Condition1Value;
public event EventHandler<Condition1EventArgs> Condition1RaisedEvent;
protected virtual void RaiseCondition1Event(Condition1EventArgs e)
{
EventHandler<Condition1EventArgs> handler = Condition1RaisedEvent;
if (handler == null)
{
return;
}
handler(this, e);
}
public void DoCondition1ButtonYesClick(object sender, EventArgs e)
{
RaiseCondition1Event(new Condition1EventArgs{
Condition1Value = Condition1Value.Value
});
}
}
Change UpdatePanel's UpdateMode property to "Always" or don't forget to call 'Update' method of UpdatePanel which UI you want to update as result of postback fired from another UpdatePanel. So try to add updateCondition2.Update method call after modalCondition2.Show method in your code.
The problem I am facing is that when there is validation on a page and I am trying to display a model pop-up, the pop-up is not getting displayed. And by using fire-bug I have noticed that an error is being thrown.
The button that is used to display the pop-up has cause validation set to false so I am stuck as to what is causing the error.
I have created a sample page to isolate the problem that I am having, any help would be greatly appreciated.
The Error
function () {Array.remove(Page_ValidationSummaries, document.getElementById("ValidationSummary1"));}(function () {var fn = function () {AjaxControlToolkit.ModalPopupBehavior.invokeViaServer("mpeSelectClient", true);Sys.Application.remove_load(fn);};Sys.Application.add_load(fn);}) is not a function
http://localhost:1131/WebForm1.aspx
Line 136
ASP
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="CLIck10.WebForm1" %>
<%# 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 runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<asp:Button ID="btnPush" runat="server" Text="Push" CausesValidation="false" onclick="btnPush_Click" />
<asp:TextBox ID="txtVal" runat="server" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtVal" ErrorMessage="RequiredFieldValidator" />
<asp:ValidationSummary ID="ValidationSummary1" runat="server" />
<asp:Panel ID="pnlSelectClient" Style="display: none" CssClass="box" runat="server">
<asp:UpdatePanel ID="upnlSelectClient" runat="server">
<ContentTemplate>
<asp:Button ID="btnOK" runat="server" UseSubmitBehavior="true" Text="OK" CausesValidation="false" OnClick="btnOK_Click" />
<asp:Button ID="btnCancel" runat="server" Text="Cancel" CausesValidation="false" OnClick="btnCancel_Click" />
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
<input id="popupDummy" runat="server" style="display:none" />
<ajaxToolkit:ModalPopupExtender ID="mpeSelectClient" runat="server"
TargetControlID="popupDummy"
PopupControlID="pnlSelectClient"
OkControlID="popupDummy"
BackgroundCssClass="modalBackground"
CancelControlID="btnCancel"
DropShadow="true" />
</div>
</form>
Code Behind
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace CLIck10
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnOK_Click(object sender, EventArgs e)
{
mpeSelectClient.Hide();
}
protected void btnCancel_Click(object sender, EventArgs e)
{
mpeSelectClient.Hide();
}
protected void btnPush_Click(object sender, EventArgs e)
{
mpeSelectClient.Show();
}
}
}
This is an issue with using both ValidationSummary and ModalPopup.
see here: http://ajaxcontroltoolkit.codeplex.com/WorkItem/View.aspx?WorkItemId=12835
The problem is that there is a missing ";" between the two injected scripts.
Their solution is to create/use a custom server control that inherits from ValidationSummary, that injects a ";" into the page startup script to fix the bug:
[ToolboxData("")]
public class AjaxValidationSummary : ValidationSummary
{
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), this.ClientID, ";", true);
}
}
Try setting your ValidationSummary "Enabled" property to false on this event : "btnPush_Click"
; and then setting it back to enabled = "true" on this events : "btnOK_Click" ,"btnCancel_Click".
I think this will work if you do not have the validation summary inside the Panel that you want to pop up.But it is not a solution if you need the validation summary inside the pop up panel,...witch is my case :(.
Best Regards.
I tried all the available answer online but didn't worked any. Then i tried to move my modal popup extender at very end of the HTML and it works fine for me. Me and my users are Happy :)
I am not using FROM tag I am using Content place holder just like below:
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<table id="tblMessage" runat="server" width="100%" >
<tr align="center">
<td align="center">
main content and
<asp:Panel ID="pnlSelectClient" Style="display: none" CssClass="box" runat="server">
<asp:ValidationSummary ID="ValidationSummary1" runat="server" />
<asp:UpdatePanel ID="upnlSelectClient" runat="server">
<ContentTemplate>
<asp:Button ID="btnOK" runat="server" UseSubmitBehavior="true" Text="OK" CausesValidation="false" OnClick="btnOK_Click" />
<asp:Button ID="btnCancel" runat="server" Text="Cancel" CausesValidation="false" OnClick="btnCancel_Click" />
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
If you notice i have validation summary inside the panel because i want error message inside the pop up(i have some additional control in pop up too). and
Some more HTML tag here as i have so many other things to do in one page. right before closing tag of TABLE
<ajaxToolkit:ModalPopupExtender ID="mpeSelectClient" runat="server"
TargetControlID="popupDummy"
PopupControlID="pnlSelectClient"
OkControlID="popupDummy"
BackgroundCssClass="modalBackground"
CancelControlID="btnCancel"
DropShadow="true" />
</table>
Done.it's working. Hope that works for other too.
Are you using validation groups anywhere on the page? I've had problems with control events not firing when they are not part of a validation group and other controls on the page are part of a validation group.
I'd try changing this:
<input id="popupDummy" runat="server" style="display:none" />
to something like this:
<asp:Button id="popupDummy" runat="server" CausesValidation="false" Visible="false" />
I bet the untyped input is requiring validation.
i had the same issue, adding ValidationGroup to the validation controls did the trick!
One other thing to try, if you don't need Client Script you can disable it in the markup. Doing that fixed our problem.
EnableClientScript="false"