Script manager won't work - c#

I have a master page and their is script manager with update panel inside it. . now i am trying to add update panel in content page without using script manager but it gives me an error:
The control with ID 'updpanel' requires a ScriptManager on the page. The ScriptManager must appear before any controls that need it.
I know i can use only one instance of script manager, then i tried ScriptManagerProxy but it gives me the error that scriptMangerProxy requires script manager.
I also tried ajax:ToolScriptManager but it also gives the same results
So the question is how can make the update panel to work in content page..
Master Page:
<%# Master Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="SideMaster.master.cs" Inherits="SideMaster" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js" type="text/jscript"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#chit').scrollTop(1000000);
});
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div class="sidemenu">
<asp:SiteMapDataSource ID="topNav" runat="server" />
<asp:Menu ID="SideMenu" runat="server" DataSourceID="topNav" CssClass="SideMenu" StaticDisplayLevels="4"
Font-Bold="true" Font-Size="20" IncludeStyleBlock="true" >
<StaticMenuItemStyle VerticalPadding="5" BackColor="#670a0a" ForeColor="White" HorizontalPadding="5" />
<StaticSelectedStyle BackColor="White" ForeColor="#670a0a" />
</asp:Menu>
</div>
<div class="cont3" >
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
<div class="rightmenu">
<div class="newspan">
<asp:Repeater ID="RepNews" runat="server" >
<HeaderTemplate><div class="newsheadcont">News & Events</div></HeaderTemplate>
<ItemTemplate>
<div class="newstemp">
<hr />
# <%#Eval("News") %>
<asp:LinkButton ID="LinkNews" runat="server" CssClass="welcomeMore"></asp:LinkButton>
</div>
</ItemTemplate>
</asp:Repeater>
</div>
<br /><br />
<div class="chatcont" style="margin-left:1%;">
<div class="chat">
<h2 class="chathead">Peoples Talking About </h2>
<asp:ScriptManager ID="scmang" runat="server"></asp:ScriptManager>
<%--<ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</ajaxToolkit:ToolkitScriptManager>--%>
<script type="text/javascript">
var xPos, yPos;
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_beginRequest(BeginRequestHandler);
prm.add_endRequest(EndRequestHandler);
function BeginRequestHandler(sender, args) {
xPos = $get('chit').scrollLeft;
yPos = $get('chit').scrollTop;
}
function EndRequestHandler(sender, args) {
$get('chit').scrollLeft = xPos;
$get('chit').scrollTop = yPos;
}
</script>
<asp:UpdatePanel ID="updPanelChat" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional" >
<ContentTemplate>
<asp:Panel ID="pan" runat="server">
<asp:ListView ID="ListChat" runat="server" >
<LayoutTemplate>
<div class="chattemp" style="width:250px; " id="chit" >
<asp:PlaceHolder runat="server" ID="itemPlaceholder"></asp:PlaceHolder>
</div>
</LayoutTemplate>
<ItemSeparatorTemplate><hr /></ItemSeparatorTemplate>
<EmptyDataTemplate>No Data Found</EmptyDataTemplate>
<ItemTemplate>
<div class="chatbox" >
<div class="chatpic" style="margin:18px 0px 0px 0px;" >
<asp:ImageButton ID="ImageChat" runat="server"
ToolTip='<%#Eval("UserName") %>'
ImageUrl='<%# "~/ShowImage.ashx?Name=" + Server.UrlEncode(Eval("UserName").ToString()) %>'
PostBackUrl='<%#"~/Profile/Profile.aspx?Name="+Eval("UserName") %>'
Width="50" Height="50" />
</div>
<div class="chatbubble" style="width:160px; margin:-50px 5px 5px 60px; float:left;">
<asp:Label ID="LabelChat" runat="server" Width="100" Height="50"><%#Eval("Body") %></asp:Label>
</div>
<div class="chatname" style="width:50px; border:none;" >
<asp:LinkButton ID="LinkUserName" runat="server"
PostBackUrl='<%#"~/Profile/Profile.aspx?Name="+Eval("UserName") %>'><%#Eval("UserName") %></asp:LinkButton>
</div>
</div>
</ItemTemplate>
</asp:ListView>
<asp:Timer ID="TimerUpdate" runat="server" Interval="20000"
ontick="TimerUpdate_Tick"></asp:Timer>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
<div class="messagebox" style="width:250px; height:120px; border:none;">
<asp:TextBox ID="TextBoxMessage" runat="server" TextMode="MultiLine" Visible="false" Width="250" Height="80" MaxLength="500"></asp:TextBox>
<asp:Button ID="ButtonMessage" runat="server" Text="Comment"
onclick="ButtonMessage_Click" Visible="false" />
</div>
</div>
</div>
</div>
</asp:Content>
Content Page:
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div class="interface" >
<table>
<tr>
<td align="center">
<div class="goog">
<asp:LinkButton ID="LinkFind" runat="server" CssClass="linkgoog">Find</asp:LinkButton>
</div>
</td></tr>
<tr><td align="left">
<div>
<asp:TextBox ID="TextBoxSearch" runat="server" Width="600" Height="40"></asp:TextBox>
<asp:Button ID="ButtonSearch" runat="server" Text="SEARCH" CssClass="loginbt"
onclick="ButtonSearch_Click1" /><br />
</div>
</td></tr>
</table>
</div>
<br />
<div class="interface">
<asp:UpdatePanel ID="updpanel" runat="server">
<ContentTemplate>
<asp:GridView ID="GridAll" runat="server"
onitemcommand="GridAll_ItemCommand" AutoGenerateColumns="false" CellPadding="10" AllowPaging="true" PageSize="3" OnPageIndexChanging="GridAll_PageIndexChanging" >
<Columns>
<asp:TemplateField HeaderText="Name" HeaderStyle-BackColor="#670a0a" HeaderStyle-ForeColor="White" HeaderStyle-Font-Size="20">
<ItemTemplate>
<asp:LinkButton ID="lnkname" runat="server"
Text='<%#Eval("Name") %>'
PostBackUrl='<%#"~/Profile/Profile.aspx?Name="+Eval("UserName") %>' CssClass="welcomeMore"/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Department" HeaderStyle-BackColor="#670a0a" HeaderStyle-ForeColor="White" HeaderStyle-Font-Size="20" >
<ItemTemplate>
<span class="googtext"><%#Eval("Department") %></span>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Year" HeaderStyle-BackColor="#670a0a" HeaderStyle-ForeColor="White" HeaderStyle-Font-Size="20">
<ItemTemplate>
<span class="googtext"><%#Eval("Year") %></span>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Photo" HeaderStyle-BackColor="#670a0a" HeaderStyle-ForeColor="White" HeaderStyle-Font-Size="20">
<ItemTemplate>
<asp:Image ID="ImageProfile" runat="server" ImageUrl = '<%# "~/ShowImage.ashx?Name=" + Server.UrlEncode(Eval("UserName").ToString()) %>' Width="150" Height="150" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
<div class="emptytext">No Match Found</div>
</EmptyDataTemplate>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</asp:Content>
Your help will be appreciated. . . Thank you

You should have only one script manager in master page above update panel.
In any of the content page you can use update panel as there is already script manager in master page. Also you should provide some code for your problem.

Related

Is it possible to refresh the whole page using an updateprogress?

I'm trying to implement a reinitialization button in my page which is linked to an UpdatePanel (AsyncPostBackTrigger). When i click on the button, it deals with an UpdateProgress.
The problem is that, because the reinitialization button is linked with an update panel, it cannot reinitialize what is outside of the UpdatePanel.
Is there a way to do some changes to the controls outside of the UpdatePanel without adding an UpdatePanel for the whole page ? In this case, i want to reinitialize the DropDownLists, the Textbox and the Repeater contained in the UpdatePanel.
How the page is rendered
ASPX code :
<body style="padding: 50px;">
<form id="form1" runat="server">
<asp:Label runat="server" ID="test"></asp:Label>
<asp:HiddenField runat="server" ID="AllDemandsTypeHfi"></asp:HiddenField>
<asp:ScriptManager runat="server" ID="ScriptManager"></asp:ScriptManager>
<asp:Panel runat="server" CssClass="panel-page-title">Création de demande</asp:Panel>
<asp:Panel runat="server" CssClass="panel-primary">
<asp:Panel runat="server" CssClass="panel-heading">Configuration de la recherche</asp:Panel>
<asp:Panel runat="server" CssClass="panel-body">
<asp:Table runat="server">
<asp:TableRow ID="BankRow">
<asp:TableCell>
<asp:Label runat="server">Banque : </asp:Label>
</asp:TableCell>
<asp:TableCell>
<asp:DropDownList runat="server" ID="BankDdl" AutoPostBack="true" OnSelectedIndexChanged="BankDdl_SelectedIndexChanged"></asp:DropDownList>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<asp:Label runat="server">Famille : </asp:Label>
</asp:TableCell>
<asp:TableCell>
<asp:DropDownList runat="server" ID="FamilyDdl" AutoPostBack="true" OnSelectedIndexChanged="FamilyDdl_SelectedIndexChanged"></asp:DropDownList>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<asp:Label runat="server">Motif : </asp:Label>
</asp:TableCell>
<asp:TableCell>
<asp:DropDownList runat="server" ID="MotiveDdl" AutoPostBack="true" OnSelectedIndexChanged="MotiveDdl_SelectedIndexChanged"></asp:DropDownList>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<asp:Label runat="server">Sous-motif : </asp:Label>
</asp:TableCell>
<asp:TableCell>
<asp:DropDownList runat="server" ID="SubmotiveDdl" AutoPostBack="true" OnSelectedIndexChanged="SubmotiveDdl_SelectedIndexChanged"></asp:DropDownList>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<asp:Label runat="server">Mots-clés : </asp:Label>
</asp:TableCell>
<asp:TableCell>
<asp:TextBox runat="server" ID="KeywordsTbx" data-target="#modalSuggestions" data-toggle="modal"></asp:TextBox>
<div id="keywordsTbxSuggestions"></div>
<asp:HiddenField runat="server" ID="KeywordsSearchHfi"></asp:HiddenField>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
<br />
<asp:Button runat="server" ID="ResearchBtn" Text="Rechercher" OnClick="ResearchBtn_Click" />
<asp:Button runat="server" ID="ReinitializeBtn" Text="Réinitialiser" OnClick="ReinitializeBtn_Click" />
</asp:Panel>
</asp:Panel>
<br />
<asp:UpdatePanel runat="server" ID="ResultsUpnl" ChildrenAsTriggers="true" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel runat="server" CssClass="panel-primary">
<asp:Panel runat="server" CssClass="panel-heading">Résultat de la recherche </asp:Panel>
<asp:Panel runat="server" CssClass="panel-body">
<asp:Label runat="server" ID="ResultsLb" Text="Veuillez sélectionner les critères de recherche, puis cliquer sur Rechercher."></asp:Label>
<asp:Repeater runat="server" ID="ResultsRpt">
<HeaderTemplate>
<asp:Label runat="server" Text="<b>Type de demande</b>"></asp:Label>
<table>
</HeaderTemplate>
<ItemTemplate>
<asp:Panel runat="server">
<asp:HyperLink runat="server" NavigateUrl='<%# Eval("Link") %>' Text='<%# Eval("Title") %>' Target="_blank"></asp:HyperLink>
</asp:Panel>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</asp:Panel>
</asp:Panel>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ResearchBtn" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="ReinitializeBtn" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UppDemandsResult" runat="server" DisplayAfter="0">
<ProgressTemplate>
<div style="text-align: center;">
<table style="width: 100%;">
<tr>
<td>
<Loader:LoaderComponent ID="UcLoadingProgess" runat="server" />
</td>
</tr>
</table>
</div>
</ProgressTemplate>
</asp:UpdateProgress>
</form>
</body>
Code-behind :
private void HandleReinitialization()
{
this.ResultsLb.Text = DemandCreationConstants.ResearchDefaultText;
this.familyDdlSelectedValue = string.Empty;
this.motiveDdlSelectedValue = string.Empty;
this.submotiveDdlSelectedValue = string.Empty;
this.LoadFamilies(true);
this.LoadMotives(false);
this.LoadSubmotives(false);
this.ResultsRpt.DataSource = null;
this.ResultsRpt.DataBind();
this.KeywordsSearchHfi.Value = string.Empty;
this.KeywordsTbx.Text = string.Empty;
LogServiceInstance.Debug("L'utilisateur " + UserSession.UserLogOn + " a réinitialisé la recherche.");
}
HandleReinitialization is launched by the event ReinitializeBtn_Click.
If understand you correctly, you will need to create UpdatePanel2 and add whatever controls into it, then in the button Click() method of the first UpdatePanel1 invoke the Update() method.
UpdatePanel2.Update();
Update:
Make sure you set the UpdateMode of UpdatePanel2 to "Conditional"
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
// Your controls
</ContentTemplate>
</asp:UpdatePanel>

Ajax Autocomplete Not Pulling Data

Okay, I have searched and searched, and methods that work for others don't seem to be working for me. I am trying to get AJAX's autocomplete to work but I have had no luck. Eventually, I want a textbox with autocomplete, pulling data from a sqldatasource, but first, I just want it to work. So, I have tried a simple implementation that I found on this website. The individual who used this code got it to work using this code, but my textbox functions just like an ordinary textbox (with no autocomplete features). I am fairly new to web dev and would appreciate any assistance. Thanks.
UPDATE:
Okay...I tried making a new, simple, webpage and tried to do the autocomplete thing again. I get this bizarre result (Single characters that make no sense):
Incorrect Autocomplete Image
aspx code
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public static string[] GetCompletionList(string prefixText, int count)
{
string[] results = { "test", "test", "test" };
return results;
}
cs. code
<asp:Label ID="FieldLabel" Text="Label:" runat="server"></asp:Label>
<asp:TextBox ID="InputField" runat="server"></asp:TextBox>
<ajaxToolkit:AutoCompleteExtender
ID="Autocompleter"
TargetControlID="InputField"
ServiceMethod="GetCompletionList"
ServicePath="~/BatchReleaseStatus.aspx"
MinimumPrefixLength="1"
CompletionInterval="1000"
runat="server">
</ajaxToolkit:AutoCompleteExtender>
Site.Master
<%# Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="CrownLabsDbFrontEnd.SiteMaster" %>
<!DOCTYPE html>
<html lang="en">
<head runat="server">
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title><%: Page.Title %> - Crown Labs Quality Database</title>
<asp:PlaceHolder runat="server">
<%: Scripts.Render("~/bundles/modernizr") %>
</asp:PlaceHolder>
<webopt:bundlereference runat="server" path="~/Content/css" />
<link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<style type="text/css">
.auto-style1 {
width: 131px;
height: 91px;
}
</style>
</head>
<body>
<form runat="server">
<asp:ScriptManager runat="server" EnablePageMethods="true" EnableScriptGlobalization="true">
<Scripts>
<%--To learn more about bundling scripts in ScriptManager see http://go.microsoft.com/fwlink/?LinkID=301884 --%>
<%--Framework Scripts--%>
<asp:ScriptReference Name="MsAjaxBundle" />
<asp:ScriptReference Name="jquery" />
<asp:ScriptReference Name="bootstrap" />
<asp:ScriptReference Name="respond" />
<asp:ScriptReference Name="WebForms.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebForms.js" />
<asp:ScriptReference Name="WebUIValidation.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebUIValidation.js" />
<asp:ScriptReference Name="MenuStandards.js" Assembly="System.Web" Path="~/Scripts/WebForms/MenuStandards.js" />
<asp:ScriptReference Name="GridView.js" Assembly="System.Web" Path="~/Scripts/WebForms/GridView.js" />
<asp:ScriptReference Name="DetailsView.js" Assembly="System.Web" Path="~/Scripts/WebForms/DetailsView.js" />
<asp:ScriptReference Name="TreeView.js" Assembly="System.Web" Path="~/Scripts/WebForms/TreeView.js" />
<asp:ScriptReference Name="WebParts.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebParts.js" />
<asp:ScriptReference Name="Focus.js" Assembly="System.Web" Path="~/Scripts/WebForms/Focus.js" />
<asp:ScriptReference Name="WebFormsBundle" />
<%--Site Scripts--%>
</Scripts>
</asp:ScriptManager>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" runat="server" href="~/"><img alt="Crown Labs Logo" class="auto-style1" src="file:///C:/Users/bcampbell/Pictures/logo_crown.gif" /></a> </div>
<div class="navbar-collapse collapse" style="padding-top:50px">
<ul class="nav navbar-nav">
<li><a runat="server" href="~/">Home</a></li>
<li><a runat="server" href="~/BatchReleaseStatus">Batch Release Status</a></li>
<li><a runat="server" href="~/CAPA">CAPA</a></li>
<li><a runat="server" href="~/Investigations">Investigations</a></li>
<li><a runat="server" href="~/Validations">Validations</a></li>
<li><a runat="server" href="~/Administration">Administration</a></li>
</ul>
<asp:LoginView runat="server" ViewStateMode="Disabled">
<AnonymousTemplate>
<ul class="nav navbar-nav navbar-right">
<li><a runat="server" href="~/Account/Register">Register</a></li>
<li><a runat="server" href="~/Account/Login">Log in</a></li>
</ul>
</AnonymousTemplate>
<LoggedInTemplate>
<ul class="nav navbar-nav navbar-right">
<li><a runat="server" href="~/Account/Manage" title="Manage your account">Hello, <%: Context.User.Identity.GetUserName() %> !</a></li>
<li>
<asp:LoginStatus runat="server" LogoutAction="Redirect" LogoutText="Log off" LogoutPageUrl="~/" OnLoggingOut="Unnamed_LoggingOut" />
</li>
</ul>
</LoggedInTemplate>
</asp:LoginView>
</div>
</div>
</div>
<div class="container body-content">
<hr />
<footer>
<p>© <%: DateTime.Now.Year %> - My ASP.NET Application<asp:ContentPlaceHolder ID="MainContent" runat="server">
</asp:ContentPlaceHolder>
</footer>
</div>
</form>
<script src="Scripts/currentClass.js"></script>
</body>
</html>
BatchReleaseStatus.aspx
<%# Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="BatchReleaseStatus.aspx.cs" Inherits="CrownLabsDbFrontEnd.BatchReleaseStatus" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<p><%--The following <p>'s keep the content from going under the Master Header --%>
<p> <p>
<asp:Button ID="btnShow_ClientSide" runat="server"
Text="show client side" OnClientClick="return false" />
<asp:Button ID="btnShow_ServerSide" runat="server"
Text="show server side" OnClick="btnShow_ServerSide_Click" />
<ajaxToolKit:ModalPopupExtender ID="mdlPopup" runat="server"
TargetControlID="btnShow_ClientSide"
PopupControlID="pnlPopup" CancelControlID="btnHide_ClientSide"
BackgroundCssClass="modalBackground" />
<asp:Panel ID="pnlPopup" runat="server"
BackColor="#CCFFFF" BorderColor="#FF6699" style="text-align: left">
Batch Number:
<asp:TextBox ID="BatchNumTextBox" runat="server"></asp:TextBox>
Part:
<br />
<asp:Button ID="btnHide_ClientSide" runat="server"
Text="hide client side" OnClientClick="return false" OnClick="btnHide_ClientSide_Click" />
<asp:Button ID="btnHide_ServerSide" runat="server"
Text="hide server side" OnClick="btnHide_ServerSide_Click" />
</asp:Panel>
<asp:Label ID="FieldLabel" Text="Label:" runat="server"></asp:Label>
<asp:TextBox ID="InputField" runat="server"></asp:TextBox>
<ajaxToolkit:AutoCompleteExtender
ID="Autocompleter"
TargetControlID="InputField"
ServiceMethod="GetCompletionList"
ServicePath="~/BatchReleaseStatus.aspx"
MinimumPrefixLength="1"
CompletionInterval="1000"
runat="server">
</ajaxToolkit:AutoCompleteExtender>
<p>
<asp:SqlDataSource ID="BatchReleaseData" runat="server" ConnectionString="<%$ ConnectionStrings:TestDBConnectionString %>" SelectCommand=<%# ViewState["stringInViewState"] %>></asp:SqlDataSource>
<%--Set up the stationary header for the primary GridView --%>
<div style =" background-color:navy;
height:30px;width:450px; margin-left:auto; margin-right:auto">
<table cellspacing="0" cellpadding = "0" border="0" id="tblHeader"
style="font-family:Arial;font-size:10pt;width:438px;color:white;
border-collapse:collapse;height:100%;">
<tr>
<%--Sets up the link buttons that will populate the header and allow sorting --%>
<td style ="width:165px;text-align:center">
<asp:LinkButton ID="MfgDatLnkBtn" runat="server" OnClick="MfgDatLnkBtn_Click" ForeColor="White">Manufacture Date</asp:LinkButton>
</td>
<td style ="width:140px;text-align:center">
<asp:LinkButton ID="BatchLnkBtn" runat="server" OnPreRender="LinkButtons_PreRender" OnClick="BatchLnkBtnClck">Batch ID</asp:LinkButton>
</td>
<td style ="width:135px;text-align:center">
<asp:LinkButton ID="DescriptionLnkBtn" runat="server" OnPreRender="LinkButtons_PreRender" OnClick="DescriptionLnkBtn_Click">Description</asp:LinkButton>
</td>
<td style ="width:140px;text-align:center">
<asp:LinkButton ID="BaseLnkBtn" runat="server" OnPreRender="LinkButtons_PreRender" OnClick="BaseLnkBtn_Click">Base</asp:LinkButton>
</td>
</tr>
</table>
</div>
<div style="margin-left:auto; margin-right:auto; width:450px; overflow:auto; height:450px; border:solid">
<table class="nav-justified">
<tr>
<td style="text-align: center">
<div style="margin-left:auto; margin-right:auto">
<asp:GridView ID="BatchReleaseGV" DataSourceId="BatchReleaseData" DataKeyNames="Mfg_Date" AutoGenerateColumns="false" ShowHeader="false"
runat="server" OnSelectedIndexChanged="BatchReleaseGV_SelectedIndexChanged" OnRowDataBound="BatchReleaseGV_RowDataBound">
<Columns>
<asp:BoundField ItemStyle-Width = "150px" DataField="Mfg_Date" HeaderText="Manufacture Date" DataFormatString="{0:MM/dd/yyyy }" HtmlEncode=false >
<ItemStyle Font-Size="Large" />
</asp:BoundField>
<asp:BoundField ItemStyle-Width = "150px" DataField="Batch" HeaderText="Batch ID"
FooterText="">
<FooterStyle CssClass="FooterStyle" />
</asp:BoundField >
<asp:BoundField ItemStyle-Width = "150px" DataField="Product" HeaderText="Description" />
<asp:BoundField ItemStyle-Width = "150px" DataField="Base" HeaderText="Base (if applicable)" />
</Columns>
</asp:GridView>
</div>
</td>
</tr>
</table>
</div>
<p>
<asp:SqlDataSource ID="BatchReleaseDataMfgDateOnly" runat="server" ConnectionString="<%$ ConnectionStrings:TestDBConnectionString %>" SelectCommand="SELECT DISTINCT CONVERT(date,[Mfg Date]) AS Mfg_Date FROM [Batch Info] ORDER BY [Mfg_Date] DESC"></asp:SqlDataSource>
<asp:SqlDataSource ID="BatchReleaseDataBatchOnly" runat="server" ConnectionString="<%$ ConnectionStrings:TestDBConnectionString %>" SelectCommand="SELECT DISTINCT [Batch] FROM [Batch Info] ORDER BY [Batch]"></asp:SqlDataSource>
<asp:SqlDataSource ID="BatchReleaseDataProductOnly" runat="server" ConnectionString="<%$ ConnectionStrings:TestDBConnectionString %>" SelectCommand="SELECT DISTINCT [Product] FROM [Batch Info] ORDER BY [Product]"></asp:SqlDataSource>
<asp:SqlDataSource ID="BatchReleaseDataBaseOnly" runat="server" ConnectionString="<%$ ConnectionStrings:TestDBConnectionString %>" SelectCommand="SELECT DISTINCT [Base] FROM [Batch Info] ORDER BY [Base]"></asp:SqlDataSource>
</p>
<table class="nav-justified">
<tr>
<td class="text-right">Manufacturing Date:
</td>
<td class="text-left">
<asp:TextBox ID="MfgDateTxtBx" runat="server"></asp:TextBox>
<ajaxToolkit:CalendarExtender ID="MfgDateTxtBx_CalendarExtender" runat="server" TargetControlID="MfgDateTxtBx" />
<asp:RegularExpressionValidator ID="MfgDateValidator" runat="server" ControlToValidate="MfgDateTxtBx" ErrorMessage="Invalid Date Entered" ValidationExpression="^((0?[13578]|10|12)(-|\/)(([1-9])|(0[1-9])|([12])([0-9]?)|(3[01]?))(-|\/)((19)([2-9])(\d{1})|(20)([01])(\d{1})|([8901])(\d{1}))|(0?[2469]|11)(-|\/)(([1-9])|(0[1-9])|([12])([0-9]?)|(3[0]?))(-|\/)((19)([2-9])(\d{1})|(20)([01])(\d{1})|([8901])(\d{1})))$" Font-Bold="True" ForeColor="Red"></asp:RegularExpressionValidator>
</td>
<td> Batch ID:
<asp:DropDownList ID="BatchDropDown" runat="server" DataSourceID="BatchReleaseDataBatchOnly" DataValueField="Batch">
</asp:DropDownList>
</td>
<td> Description:
<asp:DropDownList ID="ProductDropDown" runat="server" DataSourceID="BatchReleaseDataProductOnly" DataValueField="Product">
</asp:DropDownList>
</td>
<td>Base: <asp:DropDownList ID="BaseDropDown" runat="server" DataSourceID="BatchReleaseDataBaseOnly" DataValueField="Base">
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="text-right">To (Optional): </td>
<td style="text-align: left">
<asp:TextBox ID="DateRangeTxtBx" runat="server"></asp:TextBox>
<ajaxToolkit:CalendarExtender ID="DateRangeTxtBx_CalendarExtender" runat="server" TargetControlID="DateRangeTxtBx" />
<asp:RegularExpressionValidator ID="MfgDateRangeValidator" runat="server" ControlToValidate="DateRangeTxtBx" ErrorMessage="Invalid Date Entered" ValidationExpression="^((0?[13578]|10|12)(-|\/)(([1-9])|(0[1-9])|([12])([0-9]?)|(3[01]?))(-|\/)((19)([2-9])(\d{1})|(20)([01])(\d{1})|([8901])(\d{1}))|(0?[2469]|11)(-|\/)(([1-9])|(0[1-9])|([12])([0-9]?)|(3[0]?))(-|\/)((19)([2-9])(\d{1})|(20)([01])(\d{1})|([8901])(\d{1})))$" Font-Bold="True" ForeColor="Red" Display="Dynamic"></asp:RegularExpressionValidator>
<asp:CompareValidator id="MfgDateRangeComparator" runat="server"
ControlToCompare="MfgDateTxtBx" cultureinvariantvalues="true"
display="Dynamic" enableclientscript="true"
ControlToValidate="DateRangeTxtBx"
ErrorMessage="Start date must be earlier than finish date"
type="Date" setfocusonerror="true" Operator="GreaterThanEqual"
text="Start date must be earlier than finish date" Font-Bold="True" ForeColor="Red"></asp:CompareValidator>
</td>
<td>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<ajaxToolkit:AutoCompleteExtender ID="TextBox3_AutoCompleteExtender" runat="server" TargetControlID="TextBox3" MinimumPrefixLength="1" ServiceMethod="GetCompletionList" ServicePath="BatchReleaseStatus.aspx">
</ajaxToolkit:AutoCompleteExtender>
</td>
<td> </td>
<td> </td>
</tr>
</table>
<p>
<asp:Button ID="submitBtn" runat="server" OnClick="submitBtn_Click" Text="Submit" />
</p>
<p>
</p>
</asp:Content>
In order to use System.Web.Services.WebMethod in a codebehind file from an aspx Site, this method must be static. Also your scriptmanager need to have "EnablePageMethods=true" setted.
=> This approach is called PageMethods.
I think it's better to use WebApi instead of PageMethods, you can easily integerate this into your asp.net project. Here you will find a startpoint.
Getting started with Web-API
PageMethod-Test:
<script type="text/javascript">
function Test() {
PageMethods.Test(function(result){alert(result);});
}
[System.Web.Services.WebMethod]
public static string Test()
{
return "Hello StackOverflow";
}

Postback is not working in JQuery dialog

Hello I have the following problem I tried and nothing , I can not recover my text box user control , the TexBox will use them in the EDIT POPUP
CONVENIO.ASPX
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="convenios.aspx.cs" Inherits="convenios5.convenios" %>
<%# Register TagPrefix="ModalPopup" TagName="detalle" Src="~/UserControls/Popup_conveniodetalle.ascx"%>
<%# Register TagPrefix="ModalPopup" TagName="editar" Src="~/UserControls/Popup_conveniomodificar.ascx"%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
<link href="Styles/GridStyle.css" rel="stylesheet" type="text/css" />
<%--<link href="Styles/bootstrap.css" rel="stylesheet" type="text/css" />--%>
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js'></script>
<link href="http://code.jquery.com/ui/1.11.4/themes/ui-lightness/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<%-- CERRAR DIALOG UI --%>
<script type="text/javascript">
function closeDialog() {
$("#divmodificar").dialog('close');
}
</script>
</head>
<body>
<form id="Form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div class="panel panel-default">
<div class="panel-heading">
<h3>:: CONVENIOS CLINICA CAYETANO ::</h3>
</div>
<div class="panel-body">
<asp:UpdatePanel ID="updatePanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<table width="100%">
<tr id="trMessage" runat="server" visible="false">
<td>
<asp:Label ID="lblMessage" runat="server" Text="No hay datos que mostar"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:GridView ID="gridconvenios" runat="server" AllowPaging="true" PageSize="5"
CssClass="GridStyle" BorderColor="#cbcbcb" BorderStyle="solid" OnRowCommand="gridconvenios_RowCommand" OnPageIndexChanging="gridconvenios_PageIndexChanging"
BorderWidth="1" AutoGenerateColumns="false" DataKeyNames="COD_CONVENIO" width="100%">
<AlternatingRowStyle CssClass="GridStyle_AltRowStyle" />
<HeaderStyle CssClass="GridStyle_HeaderStyle" />
<RowStyle CssClass="GridStyle_RowStyle" />
<pagerstyle cssclass="GridStyle_pagination" />
<Columns>
<asp:TemplateField HeaderText="CODIGO">
<ItemStyle HorizontalAlign="Center" width="5%" />
<ItemTemplate>
<asp:LinkButton ID="cmddetalle" runat="server" CausesValidation="False" Text='<%# Eval("COD_CONVENIO") %>' CommandName="detalle" CommandArgument='<%# Eval("COD_CONVENIO") %>' ></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ENTIDAD">
<ItemStyle width="20%" />
<ItemTemplate>
<asp:Label ID="lblRequiredDate" runat="server" Text='<%# Eval("DES_IAFA") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="CONVENIO">
<ItemStyle HorizontalAlign="Center" width="10%" />
<ItemTemplate>
<asp:Label ID="lblShippedDate" runat="server" Text='<%# Eval("DES_CONVENIO") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="INICIO">
<ItemStyle width="5%" />
<ItemTemplate>
<asp:Label ID="lblShipName" Text='<%# Eval("FEC_INI") %>' runat="server"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="FIN">
<ItemStyle width="5%" />
<ItemTemplate>
<asp:Label ID="lblShipAddress" Text='<%# Eval("FEC_INI") %>' runat="server"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="FACTOR">
<ItemStyle width="5%" />
<ItemTemplate>
<asp:Label ID="lblfactor" Text='<%# Eval("IMP_FACTORHON") %>' runat="server"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ESTADO">
<ItemStyle width="5%" />
<ItemTemplate>
<asp:Label ID="lblestado" Text='<%# Eval("EST_CONVENIO") %>' runat="server"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemStyle HorizontalAlign="Center" width="5%" />
<ItemTemplate>
<asp:ImageButton ID="cmdEdit" CommandName="editar" CommandArgument='<%# Eval("COD_CONVENIO")%>' runat="server" ImageUrl="~/images/edit.gif" CausesValidation="False"></asp:ImageButton>
<asp:ImageButton ID="cmdDelete" CommandName="eliminar" CommandArgument='<%# Eval("COD_CONVENIO")%>' runat="server" ImageUrl="~/images/delete.gif" CausesValidation="False"></asp:ImageButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
<div id="divmodificar" style="display:none;">
<asp:UpdatePanel ID="UpdatePanel3" runat="server">
<ContentTemplate>
<ModalPopup:editar ID="ucmodificar" runat="server" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="gridconvenios" EventName="RowCommand" />
</Triggers>
</asp:UpdatePanel>
</div>
</div>
</div>
</form>
</body>
</html>
CONVENIOS.ASPX.CS
protected void gridconvenios_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e)
{
string COD_CONVENIO = Convert.ToString(e.CommandArgument);
switch (e.CommandName.ToLower())
{
case "editar":
System.Text.StringBuilder sb1 = new System.Text.StringBuilder();
sb1.Append("<script type='text/javascript'>");
sb1.Append(" $(\"#divmodificar\").dialog({");
sb1.Append(" title: \"EDITAR CONVENIO: " + COD_CONVENIO + "\",");
sb1.Append("position:'center', width:'auto', autoresize:true, modal:true,");
sb1.Append("open: function(type,data) {");
sb1.Append("$(this).parent().appendTo(\"form\");");
sb1.Append("}");
sb1.Append("});");
sb1.Append("</script>");
var ucmodificar1 = (convenios5.UserControls.Popup_conveniomodificar)ucmodificar;
ucmodificar1.BindOrderDetail(COD_CONVENIO);
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ModalScript1", sb1.ToString(), false);
break;
}
}
CONVENIOEDITAR.ASCX
<asp:Panel ID="Panel1" runat="server">
<fieldset>
<legend>DATOS CONVENIO</legend>
<table width="100%">
<tr>
<td class="cabecera">CÓDIGO: </td>
<td class="texto"><asp:Textbox ID="Text1" runat ="server"></asp:Textbox></td>
</tr>
<tr>
<td class="cabecera">DESCRIPCIÓN: </td>
<td class="texto"><asp:Textbox ID="Text2" runat="server" Width="80%"></asp:Textbox></td>
</tr>
<tr>
<td class="cabecera">FACTOR: </td>
<td class="texto"><asp:Textbox ID="Text3" runat="server" Width="80%"></asp:Textbox></td>
</tr>
<tr>
<td class="cabecera">ESTADO: </td>
<td>
<p>
<asp:RadioButton ID="activo" runat="server" Text="Activo"/>
<asp:RadioButton ID="inactivo" runat="server" Text="Inactivo"/>
</p>
</td>
</tr>
<tr>
<td colspan="2" align="right">
CONVENIOEDITAR.ASCX (HERE PROBLEM)
protected void cmdAdd_Click(object sender, EventArgs e)
{
string VAR1 = this.Text1.Text;// THIS VAR1 IS NULL
}
I can not capture the value of VAR1 appears to me as NULL.
Please help me...
I would use the onClientClick property of the asp:LinkButton, and get the textbox value via jQuery
<asp:LinkButton> .. OnClientClick="GetText1Val();" </asp:LinkButton>
And the function:
<script language="javascript">
function GetText1Val() {
var Text1Value = $("#Text1").val();
alert(Text1Value);
}
</script>

Button click reloads the page

I have strange problem.
I am implementing zero clipboard in asp.net.
First I created a page without site master and implemented the zero clipboard and it worked perfectly.
Here is the code.
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="Locker.test" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" />
</form>
<script type="text/javascript" src="Scripts/jquery-1.9.1.js"></script>
<script type="text/javascript" src="Scripts/jquery.zclip.js"></script>
<script type="text/javascript" src="Scripts/jquery.zclip.min.js"></script>
<script>
$(document).ready(function () {
$('#<%=Button1.ClientID%>').zclip({
path: 'ZeroClipboard.swf',
copy: function () { return $('#<%=TextBox1.ClientID%>').val(); }
});
});
</script>
</body>
</html>
Now when I implement this same code on the page that use Master page, it doesn't work. It trigger I reckon post back so that javascript doesn't get executed.
I checked if autopost back it true but it is set to false.
I am not sure what causing this.
Any help will be appreciated.
Here is the code of the page which use Master page.
<%# Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="searchResult.aspx.cs" Inherits="Locker.searchResult" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
<style type="text/css">
.auto-style1 {
color: #FFFFFF;
font-size: large;
}
.auto-style2 {
color: #000000;
}
.auto-style3 {
color: #000000;
font-size: large;
}
</style>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
<p>
<p>
<strong> <span class="auto-style3">Information</span><span class="auto-style1"> </span></strong>
<div style="width:70%; margin: auto auto; text-align:left;">
<asp:Panel ID="Panel1" runat="server">
<br />
<asp:Label ID="Label4" runat="server" style="font-weight: 700; font-size: large" Text="Details for :" CssClass="auto-style2"></asp:Label>
<asp:Label ID="Label5" runat="server" style="font-weight: 700; font-size: large; color: #0000FF"></asp:Label>
<br />
<br />
<asp:Label ID="Label1" runat="server" Font-Bold="False" style="font-weight: 700; font-size: large" Text="Password :" CssClass="auto-style2"></asp:Label>
<asp:TextBox ID="TextBox2" runat="server" BorderStyle="Solid" Enabled="False" Font-Size="Medium" ForeColor="Black" Width="213px"></asp:TextBox>
<asp:Button ID="Button3" runat="server" Text="Button" />
<input type="text" id="test_description" value="hi" />
<script type="text/javascript" src="Scripts/jquery-1.9.1.js"></script>
<script type="text/javascript" src="Scripts/jquery.zclip.js"></script>
<script type="text/javascript" src="Scripts/jquery.zclip.min.js"></script>
<script>
$(document).ready(function () {
$('#<%=Button3.ClientID%>').zclip({
path: 'ZeroClipboard.swf',
copy: function () { return $('#<%=TextBox2.ClientID%>').val(); }
});
});
</script>
<br />
<br />
<asp:Label ID="Label6" runat="server" style="font-weight: 700; font-size: large" Text="Description :" CssClass="auto-style2"></asp:Label>
<asp:TextBox ID="TextBox5" runat="server" BorderStyle="Solid" Enabled="False" Font-Size="Medium" Height="48px" TextMode="MultiLine" Width="213px"></asp:TextBox>
<br />
<br />
<asp:Label ID="Label7" runat="server" style="font-weight: 700; font-size: small" Text="Last Editor was " CssClass="auto-style2"></asp:Label>
<asp:Label ID="Label8" runat="server" style="font-weight: 700; font-size: small" CssClass="auto-style2"></asp:Label>
<br />
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Edit" Width="97px" />
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Update" Visible="False" Width="97px" />
<br />
<br />
<asp:Label ID="Label12" runat="server" style="font-weight: 700; font-size: large; color: #0000FF" Visible="False"></asp:Label>
<br />
<br />
<br />
<br />
</asp:Panel>
</div>
</asp:Content>
If you want to prevent postback, you may set UseSubmitBehavior to false on your Button
<asp:Button ID="Button3" runat="server" Text="Button" UseSubmitBehavior="False"/>
See UseSubmitBehavior description

ASP.NET Masterpage Implementation Error

I am using VS2005 C# ASP.NET.
I have a .aspx page with a script for user user membership management.
However, when I tried to implement Masterpage to my .aspx page, I received an error which says
Content controls have to be top-level controls in a content page or a nested master page that references a master page.
I have correctly referenced to my masterpage and I do not know where have I gone wrong.
Need help in pointing out where have I gone wrong in my .aspx page.
Thank you
Below is my code for my .aspx and masterpage:
.ASPX:
<%# Page Language="C#" MasterPageFile="~/MainPage.master"%>
<%# Import Namespace="System.Web.Security" %>
<%# Import Namespace="System.Web.UI" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" >
<script Runat="Server">
string[] rolesArray;
MembershipUserCollection users;
string[] usersInRole;
public void Page_Load()
{
Msg.Text = "";
if (!IsPostBack)
{
// Bind roles to ListBox.
rolesArray = Roles.GetAllRoles();
RolesListBox.DataSource = rolesArray;
RolesListBox.DataBind();
// Bind users to ListBox.
users = Membership.GetAllUsers();
UsersListBox.DataSource = users;
UsersListBox.DataBind();
}
if (RolesListBox.SelectedItem != null)
{
// Show users in role. Bind user list to GridView.
usersInRole = Roles.GetUsersInRole(RolesListBox.SelectedItem.Value);
UsersInRoleGrid.DataSource = usersInRole;
UsersInRoleGrid.DataBind();
}
}
public void AddUsers_OnClick(object sender, EventArgs args)
{
// Verify that a role is selected.
if (RolesListBox.SelectedItem == null)
{
Msg.Text = "Please select a role.";
return;
}
// Verify that at least one user is selected.
if (UsersListBox.SelectedItem == null)
{
Msg.Text = "Please select one or more users.";
return;
}
// Create list of users to be added to the selected role.
string[] newusers = new string[UsersListBox.GetSelectedIndices().Length];
for (int i = 0; i < newusers.Length; i++)
{
newusers[i] = UsersListBox.Items[UsersListBox.GetSelectedIndices()[i]].Value;
}
// Add the users to the selected role.
try
{
Roles.AddUsersToRole(newusers, RolesListBox.SelectedItem.Value);
// Re-bind users in role to GridView.
usersInRole = Roles.GetUsersInRole(RolesListBox.SelectedItem.Value);
UsersInRoleGrid.DataSource = usersInRole;
UsersInRoleGrid.DataBind();
Msg.Text = "User(s) added to role: " + RolesListBox.SelectedItem.Text;
return;
}
catch (Exception e)
{
Msg.Text = e.Message;
}
}
public void UsersInRoleGrid_RemoveFromRole(object sender, GridViewCommandEventArgs args)
{
// Get the selected user name to remove.
int index = Convert.ToInt32(args.CommandArgument);
string username = ((DataBoundLiteralControl)UsersInRoleGrid.Rows[index].Cells[0].Controls[0]).Text;
// Remove the user from the selected role.
try
{
Roles.RemoveUserFromRole(username, RolesListBox.SelectedItem.Value);
}
catch (Exception e)
{
Msg.Text = "An exception of type " + e.GetType().ToString() +
" was encountered removing the user from the role.";
}
// Re-bind users in role to GridView.
usersInRole = Roles.GetUsersInRole(RolesListBox.SelectedItem.Value);
UsersInRoleGrid.DataSource = usersInRole;
UsersInRoleGrid.DataBind();
Msg.Text = "User(s) removed from role: " + RolesListBox.SelectedItem.Text;
return;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Role Membership</title>
</head>
<body>
<form runat="server" id="PageForm">
<font face="helvetica" size="6" color="#455c75"><strong>Role Membership</strong></font><font face="helvetica" size="5" color="#455c75"><strong> Management</strong></font><br /><asp:Label ID="Msg" ForeColor="maroon" runat="server" /><br />
<br />
<table cellpadding="3" border="0">
<tr>
<td valign="top" style="width: 117px; height: 145px;">
<font face="helvetica" size="3" color="#455c75"><strong>Roles:</strong></font></td>
<td valign="top" style="height: 145px; width: 265px;">
<asp:ListBox ID="RolesListBox" runat="server" Rows="8" AutoPostBack="true" /></td>
<td valign="top" style="height: 145px">
<font face="helvetica" size="3" color="#455c75"><strong>Users:</strong></font></td>
<td valign="top" style="height: 145px">
<asp:ListBox ID="UsersListBox" DataTextField="Username" Rows="8" SelectionMode="Multiple"
runat="server" />
<br />
<asp:Button Text="Add User(s) to Role" ID="AddUsersButton" runat="server" OnClick="AddUsers_OnClick" /></td>
<td valign="top" style="height: 145px">
</td>
</tr>
<tr>
<td valign="top" style="width: 117px">
<font face="helvetica" size="3" color="#455c75"><strong>Users in Role:</strong></font></td>
<td valign="top" style="width: 265px">
<asp:GridView runat="server" CellPadding="4" ID="UsersInRoleGrid" AutoGenerateColumns="False"
GridLines="Horizontal" OnRowCommand="UsersInRoleGrid_RemoveFromRole" ForeColor="#333333">
<HeaderStyle BackColor="#5D7B9D" ForeColor="White" Font-Bold="True" />
<Columns>
<asp:TemplateField HeaderText="User Name" >
<ItemTemplate>
<%# Container.DataItem.ToString() %>
</ItemTemplate>
</asp:TemplateField>
<asp:ButtonField Text="Remove From Role" />
</Columns>
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<EditRowStyle BackColor="#999999" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
</td>
</tr>
</table>
</form>
</body>
</html>
</asp:Content>
Masterpage:
<%# Master Language="C#" AutoEventWireup="true" CodeFile="MainPage.master.cs" Inherits="MainPage" %>
<!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>RM</title>
<link href="Styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="wrapper">
<form id="form1" runat="server">
<div id="header" style="height: 2.7em">
<span class="title">Role Management</span>
<span class="breadcrumb">
<asp:SiteMapPath ID="SiteMapPath1" runat="server">
</asp:SiteMapPath>
</span>
</div>
<div id="content">
<asp:contentplaceholder id="MainContent"
runat="server">
<!-- Page-specific content will go here... -->
</asp:contentplaceholder>
<br />
</div>
<div id="navigation" style="top: 4.19em; left: 0.51em;">
<asp:Panel ID="Panel1" runat="server" Height="50px" Width="260px">
<font size="2">You are logged in as </font>
<asp:LoginName ID="LoginName1" runat="server" Font-Bold="False" Font-Underline="False" ForeColor="RoyalBlue" Font-Italic="False" />
<br />
<asp:LinkButton ID="Logout" runat="server" Font-Bold="True" Font-Underline="True"
OnClick="Logout_Click" Font-Size="Smaller" ToolTip="Logout">Logout</asp:LinkButton></asp:Panel>
<ul>
<li>
<asp:HyperLink runat="server" ID="lnkHome"
NavigateUrl="/SoD/Common/Default.aspx">Home</asp:HyperLink>
<asp:Repeater runat="server" ID="menu" DataSourceID="SiteMapDataSource1" EnableViewState="False">
<ItemTemplate>
<li>
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl='<%# Eval("Url") %>'>
<%# Eval("Title") %></asp:HyperLink>
<asp:Repeater ID="Repeater1" runat="server"
DataSource='<%# ((SiteMapNode) Container.DataItem).ChildNodes %>'>
<HeaderTemplate>
<ul>
</HeaderTemplate>
<ItemTemplate>
<li>
<asp:HyperLink ID="HyperLink2" runat="server"
NavigateUrl='<%# Eval("Url") %>'>
<%# Eval("Title") %></asp:HyperLink>
</li>
</ItemTemplate>
<FooterTemplate>
</ul>
</FooterTemplate>
</asp:Repeater>
</li>
</ItemTemplate>
</asp:Repeater>
</li>
</ul>
</div>
<asp:SiteMapDataSource ID="SiteMapDataSource1"
runat="server" ShowStartingNode="false" />
</form>
</div>
</body>
</html>
The <asp:Content> misses runat="server"
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server" >
One more thing remove the following tags from the .aspx file
<head> , <form>, <body>, and <html> because these tags are inherited from the Master Page

Categories

Resources