There is an UpdatePanel add inside UserControl, and this user control is added inside the MasterPage. When clicking on a button in that UpdatePanl. The whole page is refreshed. why?
Master Page:
<%# Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="webasite.SiteMaster" %>
<%# Register Src="views/uc/_aside.ascx" TagPrefix="uc1" TagName="_aside" %>
<%# Register Src="views/uc/_page-loader.ascx" TagPrefix="uc1" TagName="_pageloader" %>
<!DOCTYPE html>
<html lang="ar" direction="rtl" dir="rtl" style="direction: rtl">
<!--begin::Head-->
<head>
<base href="">
<meta charset="utf-8" />
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true"></asp:ScriptManager>
<uc1:_pageloader runat="server" id="_pageloader" />
<uc1:_aside runat="server" id="_aside" />
</form>
</body>
</html>
User control: _aside.ascx
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="_aside.ascx.cs" Inherits="cidyai.partials.uc._aside" %>
<%# Register Src="~/app/views/uc/dashboard.ascx" TagPrefix="uc2" TagName="dashboard" %>
<%# Register Src="~/app/views/uc/drivers.ascx" TagPrefix="uc1" TagName="drivers" %>
<uc2:dashboard runat="server" ID="dashboard" UpdateMode="Conditional"/>
<uc1:drivers runat="server" id="drivers" UpdateMode="Conditional"/>
User control: drivers.ascx
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="drivers.ascx.cs" Inherits="cidyai.app.views.uc.drivers" %>
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate></ProgressTemplate>
</asp:UpdateProgress>
<form class="form">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">
<ContentTemplate>
<asp:TextBox ID="txtFirstName" runat="server" CssClass="form-control form-control-solid" placeholder="Name"></asp:TextBox>
<asp:Button ID="btnSave" CssClass="btn btn-primary mr-2" runat="server" Text="save" OnClick="btnSave_Click" />
</ContentTemplate>
</asp:UpdatePanel>
</form>
Related
I have a page with a gridview that displays results from a query and has paging and a search bar. It works fine when I load it by itself with not master page however when I add the master page to it all the controls disappear. below is the code with the master page and without
<%# Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeFile="Default3.aspx.cs" Inherits="_Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent"
Runat="Server">
<%# Import Namespace="GridView" %>
<div>
<div align="center" class="padded" >
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
Font-Size="Large" OnSelectedIndexChanged="Refresh_Click">
</asp:DropDownList>
<asp:Button ID="Refresh" runat="server" OnClick="Refresh_Click"
Text="Search" Visible="False" />
</div>
<div>
<cc1:HTMLGridView ID="HTMLGridView1" runat="server"
OnRowDataBound="OnRowDataBound2"/>
</div>
Here is the code that works with no master page
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs"
Inherits="_Default" %>
<%# Register assembly="GridView" namespace="GridView" tagprefix="cc1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<div align="center" class="padded" >
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
Font-Size="Large" OnSelectedIndexChanged="Refresh_Click">
</asp:DropDownList>
<asp:Button ID="Refresh" runat="server" OnClick="Refresh_Click"
Text="Search" Visible="False" />
</div>
<cc1:HTMLGridView ID="HTMLGridView1" runat="server"
OnRowDataBound="OnRowDataBound2" allowDeleting="False" allowEditing="False"
allowView="False"/>
</form>
</body>
</html>
I also added the reference to the web.config file but I have had no luck
<add tagPrefix="cc1" namespace="GridView" assembly="GridView" />
Where am I going wrong?
Try adding
<%# Import Namespace="GridView" %>
before
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent"
Runat="Server">
I'm trying to move a page from an AJAX UpdatePanel to an Ajax Control Toolkit AccordianPane. When I run the app I get the following error :
DataBinding: 'AjaxControlToolkit.AccordionContentPanel' does not
contain a property with the name 'IsNdmaVisible'.
Here is a code snippet from the page I'm embedding in the AccordianPaneControl, with the property IsNdmaVisible in question, as referred to in the DataBinder.Eval method:
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="ScenarioEditor.ascx.cs"
Inherits="Clients.Views.Controls.ScenarioEditor" %>
<%# Register Src="~/SharedUserControls/AjaxMonthCalendar.ascx" TagName="AjaxMonthCalendar" TagPrefix="ajaxMonthCalendar" %>
<%# Register Src="~/SharedUserControls/AjaxFcdMonthCalendar.ascx" TagName="AjaxFcdMonthCalendar" TagPrefix="ajaxMonthCalendar" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<asp:UpdatePanel ID="m_ScenarioEditorUpdatePanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel ID="m_ScenarioEditorPanel" runat="server" meta:resourcekey="m_ScenarioEditorPanelResource1">
<table class="layout-table input-strech">
<tr>
<td colspan="4">
<table class="layout-table" >
<tr>
<td>
<asp:CheckBox ID="m_SnowBallCheckBox" ValidationGroup="ScenarioStrategies" runat="server"
Width="100px" meta:resourcekey="m_SnowBallCheckBox" />
</td>
<td>
<asp:CheckBox ID="m_NDMACheckBox" ValidationGroup="ScenarioStrategies" runat="server"
Width="100px" **Visible='<%# (bool)DataBinder.Eval(Container, "IsNdmaVisible") %>'**
Enabled='<%# (bool)DataBinder.Eval(Container, "IsNdmaEnabled") %>' meta:resourcekey="m_NDMACheckBox" />
</td>
</tr>
</table>
</td>
</tr>
</table>
<br />
</asp:Panel>
<div id="flag">
</div>
<asp:Literal ID="StartUpScript" runat="server" Visible="false">
<script language="javascript" type="text/javascript">
ScenarioEditor.StartUp();
</script>
</asp:Literal>
</ContentTemplate>
</asp:UpdatePanel>
Inasmuch embedding the above ScenarioEditor.ascx page, here with the original code snippet which works perfectly, followed by my new code, which obviously breaks (I'm including the assembly and code references only once for both snippets):
Reference and 'exteral' code registering:
<%# Page Title="" Language="C#" MasterPageFile="~/Shared/CareMaster.Master" AutoEventWireup="true" CodeBehind="EditScenario.aspx.cs" Inherits="Clients.Views.EditScenario" meta:resourcekey="PageResource1" %>
<%# Register Src="~/Clients/Controls/ScenarioEditor.ascx" TagName="ScenarioEditor" TagPrefix="clientControls" %>
<%# Register Src="~/SharedUserControls/CollapsibleContentPanel.ascx" TagName="CollapsibleContentPanel" TagPrefix="sharedControls" %>
<%# Register src="~/SharedUserControls/AjaxCalendar.ascx" tagname="AjaxCalendar" tagprefix="ajaxCalendar" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
Working Code:
<asp:Content ID="MainContent" ContentPlaceHolderID="MainContent" runat="server">
<sharedControls:CollapsibleContentPanel ID="m_ScenarioEditorPanel" runat="server" style="margin-bottom: 1em">
<Title>
Scenario Details
</Title>
<Content>
<div >
<asp:HiddenField ID="labelForRadio" Value="" runat="server"/>
</div>
<asp:UpdatePanel ID="ButtonsPanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div style="float:left;">
<clientControls:ScenarioEditor runat="server" ID="m_ScenarioEditor" />
</div>
</ContentTemplate>
</asp:UpdatePanel>
</Content>
</sharedControls:CollapsibleContentPanel>
</asp:Content>
My code:
<ajaxToolkit:Accordion ID="Accordian1" runat="server">
<Panes>
<ajaxToolkit:AccordionPane ID="ScenarioDetails" runat="server">
<Header>Scenario Details</Header>
<Content>
<asp:UpdatePanel ID="ButtonsPanel" runat="server" BackColor="Yellow">
<ContentTemplate>
<div style="float:left;">
<clientControls:ScenarioEditor runat="server" ID="m_ScenarioEditor" />
</div>
</ContentTemplate>
</asp:UpdatePanel>
</Content>
</ajaxToolkit:AccordionPane>
</Panes>
</ajaxToolkit:Accordion>
The code is the one below. I've tried several solution from other posts but none worked. This should be a very simple task tough. After clicking on the image, the calendar appears, the textbox is updated but when I get the .text property it still is unchanged.
Thanx for any help
<%# Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" Inherits="Comunicazioni_ClassificaInterna" Title="Classifica interna" Codebehind="ClassificaInterna.aspx.cs" %>
<%# Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" EnableScriptGlobalization="True" EnableScriptLocalization="False"> </asp:ScriptManager>
<br />
<asp:TextBox ID="tbCompetitionDate" runat="server" ReadOnly="True"></asp:TextBox>
<cc1:CalendarExtender ID="tbCompetitionDate_CalendarExtender" runat="server" PopupButtonID="imgPopup" Format="dd/MM/yyyy" BehaviorID="tbCompetitionDate_CalendarExtender" TargetControlID="tbCompetitionDate" FirstDayOfWeek="Monday" />
<asp:ImageButton ID="imgPopup" ImageUrl="../../../Resources/Pics/calendar.png" ImageAlign="Bottom" runat="server" Height="25px" Width="30px" />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="FooterPlaceHolder" runat="server">
<img alt="" src="../../Resources/Pics/Footer.png" style="margin-left:500px; margin-top:200px; width:300px;height:50px" />
</asp:Content>
I've got a .NET 4.0 WebForms project with 2 UpdatePanels and textbox in one of them. When I enter text in "Group" textbox and then click on "Save ASYNC" button, the proper server function is called but nothing comes to txtGroup. I wonder what's wrong with my project and how to fix the issue. Below is my ASPX page:
<%# Page Title="Home Page" Language="C#" MasterPageFile="~/DEF.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
<asp:Content ID="Content2" ContentPlaceHolderID="PlaceHolderBodyAreaClass" runat="server">
<link href="Content/css/jquery-ui.css" rel="stylesheet" type="text/css" />
<link href="Content/CSS/AdminStyles.css" rel="stylesheet" type="text/css" />
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">
<script type="text/javascript" src="Scripts/js/jquery-1.11.2.js"></script>
<script type="text/javascript" src="Scripts/js/jquery-ui.js"></script>
</asp:Content>
<asp:Content ID="BodyContent" ContentPlaceHolderID="PlaceHolderMain" runat="server">
<asp:UpdatePanel ID="UpdatePanel4" runat="server" >
<ContentTemplate>
<asp:Label ID="lblError" runat="server" ForeColor="Red" Text=""></asp:Label>
<asp:Button ClientIDMode="Static" ID="Button1" runat="server" Text="DIALOG"
OnClientClick="Dlg();return false;"
/>
</ContentTemplate>
</asp:UpdatePanel>
<div id="dialogQuests" class="dialogQuestsClass">
<div class="headerDivBlock">QUESTION</div>
<div class="contentDivBlock">
<asp:UpdatePanel ID="UpdatePanel6" runat="server" >
<ContentTemplate>
<table id="tableSizePositionQuest">
<tr>
<td>Group:</td>
<td>
<asp:TextBox ID="txtGroup" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="2">
<asp:Button ID="btnQuestSave" runat="server" UseSubmitBehavior="false" Text="Save ASYNC" OnClick="btnQuestSave_Click" />
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
<script type="text/javascript">
function Dlg()
{
$('#dialogQuests').dialog({ minWidth: 840, resizable: true });
}
</script>
</asp:Content>
I have problem with my UserControl. It has inside the UpdatePanel, but it must be placed inside the tag to get worked (otherwise, the PostBack is not asynchronous)
The problem is, if I put that UserControl in e.g. Default.aspx page, the error appears
"A page can have only one server-side Form tag"
how to cope with that ?
[edit]
the UserControl.ascx code:
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="PodmiotyZwolnioneCtrl.ascx.cs" Inherits="FormularzPodatkowy.PodmiotyZwolnioneCtrl" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>
<link href="AjaxStyle.css" rel="stylesheet" type="text/css" />
<!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" >
<body>
<form id="form1" runat="server">
<div>
<asp:UpdatePanel ID="UpdatePanel1"
UpdateMode="Conditional"
runat="server">
<ContentTemplate>
<fieldset>
<legend>UpdatePanel content</legend>
<!-- Other content in the panel. -->
<%=DateTime.Now.ToString() %>
<br />
<asp:Button ID="Button1"
Text="Refresh Panel"
runat="server" />
</fieldset>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
the WebForm1.aspx code:
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="FormularzPodatkowy.WebForm1" %>
<%# Register src="PodmiotyZwolnioneCtrl.ascx" tagname="PodmiotyZwolnioneCtrl" 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></title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<uc1:PodmiotyZwolnioneCtrl ID="PodmiotyZwolnioneCtrl1" runat="server" />
</form>
</body>
</html>
Your code should be:
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="PodmiotyZwolnioneCtrl.ascx.cs" Inherits="FormularzPodatkowy.PodmiotyZwolnioneCtrl" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>
<link href="AjaxStyle.css" rel="stylesheet" type="text/css" />
<div>
<asp:UpdatePanel ID="UpdatePanel1"
UpdateMode="Conditional"
runat="server">
<ContentTemplate>
<fieldset>
<legend>UpdatePanel content</legend>
<!-- Other content in the panel. -->
<%=DateTime.Now.ToString() %>
<br />
<asp:Button ID="Button1"
Text="Refresh Panel"
runat="server" />
</fieldset>
</ContentTemplate>
</asp:UpdatePanel>
</div>
It looks like you converted a page to a control and forgot to remove the page-specific elements
Also, if your postbacks are not asynchronous, look at your web.config for:
<xhtmlConformance mode="Legacy"/>
and change it to:
<xhtmlConformance mode="Transitional"/>
I just spent three days at work finding that solution to UpdatePanel always posting back to the server.
You should check both the usercontrol and the page and make sure that you only have one <form id='form1' runat='server'> tag in your markup. Having more than one will give you the error that you're experiencing.
Good luck, and hope this helps some.