Subgurim maps control wont render inside a Formview - asp.net

I want to create a subgurim maps control inside a Formview in an asp.net web form page. When I add it to an item template in a formview it wont render. When I place it outside the Formview it renders fine. Is there something I am missing?
Code where it does not render:
<%# Register Assembly="GMaps" Namespace="Subgurim.Controles" TagPrefix="maps" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="main" Runat="Server">
<div id="content">
<asp:FormView ID="FormView1" runat="server">
<ItemTemplate>
<maps:StaticGMap ID="StaticGMap1" runat="server" format="png32" />
<maps:GMap ID="GMap1" runat="server" />
</ItemTemplate>
</asp:FormView>
</div>
</asp:Content>

The problem is that Formview has not DataSourceID or DataSource. If you set a DataSource for your FormView You will see the map.

Related

Inline Server Tags Re-Eavluated on Partial Postback from UpdatePanel?

I have a web application where I'm trying to use a user control with an UpdatePanel so that the control can be updated on the web page using a partial postback.
I have defined the ScriptManager in the Master page for the site. It is place outside of the ContentPlaceHolder but inside the form tag for the body as represented below:
<head>
<asp:ContentPlaceHolder ID="HeadContent" runat="server" />
</head>
<body>
<form runat="server" class="form-horizontal">
<asp:ScriptManager ID="ScriptManager1" EnablePartialRendering="true" runat="server" />
<asp:ContentPlaceHolder ID="MainContent" runat="server" />
</body>
In the content page I have some HTML that using inline server tags to bind to data and a user control that contains the UpdatePanel as represented below:
<%# Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="ClientDetail.aspx.cs" Inherits="ClientDetail" Async="true" %>
<%# Register src="../controls/ListSelectionControl.ascx" tagname="ListSelectionControl" tagprefix="lsc" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
<link href="<%= ResolveClientUrl("~/css/clientdetail.css") %>" rel="stylesheet" type="text/css" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
<div>
Client: <%= this.CurrentClient.Id %> - <%= this.CurrentClient.Name %>
</div>
<div>
<lsc:ListSelectionControl ID="ItemsListSelectionControl" runat="server" />
</div>
</asp:Content>
The UpdatePanel in the user control includes a couple of listboxes and buttons to move items from one list to another. The buttons are registered as AsyncPostbackTriggers and are marked as CauseValidation="false" to prevent the validators in other parts of the page from firing. The UpdatePanel is represented below:
<%# Control Language="C#" AutoEventWireup="true" CodeFile="ListSelectionControl.ascx.cs" Inherits="ListSelectionControl" %>
<div>
<asp:UpdatePanel ID="udpListSelection" UpdateMode="Conditional" runat="server" ChildrenAsTriggers="false">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnAdd" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="btnRemove" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="btnAddAll" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="btnRemoveAll" EventName="Click" />
</Triggers>
<ContentTemplate>
<div>
<asp:ListBox ID="lstAvailableItems" runat="server" SelectionMode="Multiple" Rows="15" />
</div>
<div>
<asp:Button ID="btnAdd" CausesValidation="false" runat="server" OnClick="AddItems" Text="Add >" />
<asp:Button ID="btnRemove" CausesValidation="false" runat="server" OnClick="RemoveItems" Text="< Remove" />
<asp:Button ID="btnAddAll" CausesValidation="false" runat="server" OnClick="AddAllItems" Text="Add All >" />
<asp:Button ID="btnRemoveAll" CausesValidation="false" runat="server" OnClick="RemoveAllItems" Text="< Remove All" />
</div>
<div>
<asp:ListBox ID="lstSelectedItems" runat="server" SelectionMode="Multiple" Rows="15" />
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
The code behind on the buttons simply manages the exchange of the data between the list boxes and I don't believe it's relevant here.
The problem that I'm having is that when the partial postback occurs (breakpointing the code in the Master page and analysing the IsInAsyncPostback property determines that it is a partial postback) the page is processing the inline ASP server code and failing because the CurrentClient object is not being re-populated. I'm looking to understand why this is happening and why the partial postback is not simply updating my UpdatePanel as I expected?
Thank you for your assistance.
Richard
I regretfully have to inform you of some bad news... update panels have a lot of issues inside of UserControls... hopefully you can find some sort of work around.

What does <asp:Content> error mean in asp.net Master page?

I am getting the Content controls error in my Master page. I did not leave any tag opened but still getting this error. Can somebody look at my code and point me to my mistake for correction? Can somebody explain me the error via this example?
<%# Master Language="C#" MasterPageFile="~/Data.master" AutoEventWireup="true" CodeFile="IMS.master.cs" Inherits="ims_IMS" %>
<%# MasterType VirtualPath="~/AData.master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="contenttop" Runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="content" Runat="Server">
<div id="section-header" class="clear">
<h2 id="section-title">IMS </h2>
</div>
<de:PageSecurity ID="ps1" runat="server" ContentControlId="contentwrapper" AllowdeStaff="True" AllowTechss="False" AllowPeoples="False" AllowDistrict="True" ErrorMessage="You cannot access this page." />
<div id="section-content">
<asp:ContentPlaceHolder ID="sectioncontent" Runat="Server">
</asp:ContentPlaceHolder>
</div>
</asp:Content>
I'd recommend you remove everything from inside <asp:Content ID="Content3" and see if you still get an error.
Also, try ending your custom control with /> instead of /de>
<asp:scriptmanager id="ScriptManager1" runat="server" xmlns:asp="#unknown"></asp:scriptmanager>
<asp:button id="Button1" runat="server" onclick="Button1_Click" text="Button" xmlns:asp="#unknown" />
<rsweb:reportviewer id="ReportViewer2" runat="server" height="261px" width="476px" xmlns:rsweb="#unknown"></rsweb:reportviewer>

[asp.net]updatepanel refreshes only once

I have a very simple page:
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<%= DateTime.Now %>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<%= DateTime.Now %>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
This version work as I expected. From firebug I can refresh the updatepanel everytime using __doPostBack('MainContent_UpdatePanel1','').
The second version has only one new control, this is AsyncFileUpload from ajax control toolkit. This time using javascript I can only refresh the updatepanel once. Why is this happening?
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<%= DateTime.Now %>
<asp:AsyncFileUpload ID="AsyncFileUpload1" runat="server" />
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<%= DateTime.Now %>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
There seem to be a couple of issue re triggering postbacks with the upload control on the page
http://ajaxcontroltoolkit.codeplex.com/workitem/25475

Can I trigger an Update Panel from a Drop Down list in a User Control

I have a user control in a master page with two drop down lists. When the user selects an item out of either ddl, I want to load a specific user control inside an update panel on the content page. I can't figure out how to get the user control to trigger the update panel. Any suggestions are very much appreciated.
Master
<%# Register src="toolbar.ascx" tagname="toolbar" tagprefix="uc1" %>
<head id="Head1" runat="server">
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
</div>
<uc1:toolbar ID="toolbar1" runat="server" />
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</form>
</body>
</html>
User Control
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="toolbar.ascx.cs" Inherits="Blah.toolbar" %>
<asp:DropDownList ID="ddlDesiredPage" runat="server" AutoPostBack="True"
EnableViewState="True"
onselectedindexchanged="goToSelectedPage">
<asp:ListItem Value="-">DDL 1</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="ddlDesiredPageSP" runat="server" AutoPostBack="True"
EnableViewState="True"
onselectedindexchanged="goToSelectedPage">
<asp:ListItem Value="-">DDL 2</asp:ListItem>
</asp:DropDownList>
Content Page
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" onload="UpdatePanel1_Load">
<ContentTemplate>
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
</ContentTemplate>
<Triggers>
?????????????????????????????????
</Triggers>
</asp:UpdatePanel>
</asp:Content>
If you want to update the panel via the User Control you've created, you could try setting the UpdatePanel's UpdateMode = Conditional. Then, in your User Control's click event (or whichever event), have something like this:
UpdatePanel mUpdatePanel = this.Page.Master.FindControl("upContent") as UpdatePanel;
if (mUpdatePanel != null)
{
mUpdatePanel.Update();
}
else
{
//update panel not found
}
UPDATE
Since you can't access your triggers declaratively, you could add them from the code-behind. On your content page, add something like this:
AsyncPostBackTrigger triggerUserControl = new AsyncPostBackTrigger();
DropDownList ucDDL = this.Page.Master.FindControl("ddlDesiredPage") as DropDownList;
triggerUserControl.ControlID = ucDDL.ID;
triggerUserControl.EventName = "Click";
UpdatePanel1.Triggers.Add(triggerUserControl);
Do the same for the other DropDownList. I haven't tried this, but it seems reasonable.
Try adding a postback trigger to your UpdatePanel:
<Triggers>
<asp:PostBackTrigger ControlID="ddl..." />
</Triggers>

Why My Whole Page Refreshes While Using ValidatorCallOut in Ajax Control Toolkit?

I downloaded Ajax Control Toolkit and want to add its components to my project. I Used ValidatorCallOut Component as an extender of a Textbox and when user changes focus to another Textbox ValidatorCallOut pops up. but this action will cause the page to refresh. How can I prevent that?
Here is my code:
<%# Page Language="C#" MasterPageFile="~/User/UserMasterPage.master" AutoEventWireup="true"
CodeFile="New.aspx.cs" Inherits="User_Accounts_New" Title="Untitled Page" %>
<%# Register
Assembly="AjaxControlToolkit"
Namespace="AjaxControlToolkit"
TagPrefix="act" %>
<asp:Content ID="Content2" ContentPlaceHolderID="LeftContentPlaceHolder" runat="Server">
<act:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" />
<asp:TextBox ID="LoginUrlTxtb" CssClass="textEntry" TabIndex="0" runat="server" Width="321px"
OnTextChanged="LoginUrlTxtb_TextChanged" AutoPostBack="True"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ErrorMessage="Url is Not Well Formated" ControlToValidate="LoginUrlTxtb">*</asp:RegularExpressionValidator>
<act:ValidatorCalloutExtender ID="RegularExpressionValidator1_ValidatorCalloutExtender"
runat="server" HighlightCssClass="validatorCalloutHighlight"
Enabled="True" TargetControlID="RegularExpressionValidator1"
CssClass="validatorCalloutHighlight" PopupPosition="Left" Width="200px">
</act:ValidatorCalloutExtender>
<asp:TextBox ID="FirstnameTxtb" CssClass="textEntry" TabIndex="0" runat="server" Width="321px"
OnTextChanged="LoginUrlTxtb_TextChanged" AutoPostBack="True"></asp:TextBox>
</asp:Content>
Your textboxes have the "AutoPostBack" property set to true. Therefore, whenever they lose focus, they will send a postback to the server and the page will refresh.

Resources