Master Pages and Child Pages Setup - c#

I want to create a Master Page that has a toolbar (add,edit,delete,approve,unapprove) as well as a gridview as shown below. This Master Page will have a lot of children. I want to reused the gridview and the toolbar.. rather than adding both of them to each page i create.
<%# Master Language="VB" AutoEventWireup="false" CodeBehind="JSPSite.master.vb" Inherits="SSPayroll.JSPSite" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
<link href="../Styles/Style1.css" rel="stylesheet" type="text/css" />
<asp:ContentPlaceHolder ID="HeadContent" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="Form1" runat="server">
<div class="page">
<div class="header">
<div class="title">
<h1>
<asp:Image ID="Image1" runat="server" ImageUrl="~/images/GSCV1.01 - Copy.png"
Height="73px" style="margin-top: 20px" Width="428px" />
</h1>
</div>
<div class="loginDisplay">
<asp:LoginView ID="HeadLoginView" runat="server" EnableViewState="false">
<LoggedInTemplate>
<asp:Label ID="Label2" runat="server" Text="User: " Font-Names="Cambria"></asp:Label><span class="bold">
<asp:LoginName ID="HeadLoginName" runat="server" Font-Names="Cambria" />
</span> [
<asp:LoginStatus ID="HeadLoginStatus" runat="server" LogoutAction="Redirect"
LogoutPageUrl="~/" Font-Names="Cambria" Font-Size="Small" ForeColor="#D9D5D5" Font-Bold="True" LogoutText="Sign Out" />
]
<div>
</div>
</LoggedInTemplate>
<RoleGroups>
<asp:RoleGroup>
</asp:RoleGroup>
</RoleGroups>
</asp:LoginView>
<asp:Label ID="Label1" runat="server" Text="Date/Time" Font-Names="Cambria"
Font-Size="Small" ForeColor="#333333"></asp:Label>
</div>
<div class="clear hideSkiplink">
<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="False"
IncludeStyleBlock="False" Orientation="Horizontal" BackColor="#FFFBD6"
DynamicHorizontalOffset="2" Font-Names="Verdana" Font-Size="0.8em"
ForeColor="#990000" StaticSubMenuIndent="10px" Enabled="True">
<DynamicHoverStyle BackColor="#990000" ForeColor="White" />
<DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
<DynamicMenuStyle BackColor="#FFFBD6" />
<DynamicSelectedStyle BackColor="#FFCC66" />
<Items>
<asp:MenuItem Text="Menu1" Value="Tools">
<asp:MenuItem NavigateUrl="~/JSPayroll/Payment_Rules/PaymentRules.aspx" Text="Payment Rules" Value="Payment Rules"></asp:MenuItem>
</asp:MenuItem>
</Items>
<StaticHoverStyle BackColor="#990000" ForeColor="White" />
<StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
<StaticSelectedStyle BackColor="#FFCC66" />
</asp:Menu>
</div>
</div>
<asp:ContentPlaceHolder ID="ToolBarPlaceHolder" runat="server" >
<asp:Panel ID="Panel1" runat="server" HorizontalAlign="Center">
<div>
<hr />
<asp:ImageButton ID="ImageButton1" runat="server" Height="48px" ImageUrl="~/IconsPack/Home.png" Width="48px" ToolTip="Home" CssClass="morph" PostBackUrl="~/JSPayroll/JSPDefault.aspx"/>
<asp:ImageButton ID="ImageButton2" runat="server" Height="48px" ImageUrl="~/IconsPack/Add.png" PostBackUrl="~/JSPayroll/Payment_Rules/PaymentRulesDetails.aspx" ToolTip="Add Record" CssClass="morph" Width="48px"/>
<asp:ImageButton ID="ImageButton3" runat="server" Height="48px" ImageUrl="~/IconsPack/Edit E.png" ToolTip="Edit Record" CssClass="morph" Width="48px" />
<asp:ImageButton ID="ImageButton4" runat="server" Height="48px" ImageUrl="~/IconsPack/ViewDetails.png" ToolTip="View Record Details" CssClass="morph" Width="48px" />
<asp:ImageButton ID="ImageButton5" runat="server" Height="48px" ImageUrl="~/IconsPack/Delete.png" ToolTip="Delete Record" CssClass="morph" Width="48px" />
<asp:ImageButton ID="ImageButton6" runat="server" Height="48px" ImageUrl="~/IconsPack/Approved.png" ToolTip="Approve Record" CssClass="morph" Width="48px"/>
<asp:ImageButton ID="ImageButton7" runat="server" Height="48px" ImageUrl="~/IconsPack/Denied.png" ToolTip="Unapprove Record" CssClass="morph" Width="48px"/>
<asp:ImageButton ID="ImageButton8" runat="server" Height="48px" ImageUrl="~/IconsPack/Update.png" ToolTip="Refresh Table" CssClass="morph" Width="48px"/>
<hr />
</div>
</asp:Panel>
</asp:ContentPlaceHolder>
<asp:ContentPlaceHolder ID="GridViewPlaceHolder" runat="server">
<div class="EU_TableScroll" id="showData" style="display: block">
<asp:GridView ID="GridView1" runat="server" CssClass="EU_DataTable" AllowPaging="True"
PageSize="7" AutoGenerateColumns="False" EmptyDataText="No Data Available.">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</asp:ContentPlaceHolder>
<asp:ContentPlaceHolder ID="DataSource" runat="server">
</asp:ContentPlaceHolder>
<div class="clear">
</div>
</div>
<div class="footer">
</div>
</form>
</body>
</html>
An Example of a Child Page using the master page from above.
<%# Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/JSPayroll/JSPSite.Master" CodeBehind="PaymentRules.aspx.vb" Inherits="SSPayroll.PaymentRules" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="DS" ContentPlaceHolderID ="DataSource" runat ="server">
<asp:EntityDataSource ID="EntityDataSource1" runat="server" ConnectionString="name=sspEntities" DefaultContainerName="sspEntities" EnableDelete="True" EnableFlattening="False" EnableInsert="True" EnableUpdate="True" EntitySetName="GeneralRules">
</asp:EntityDataSource>
</asp:Content>
Basically what i want to do is.. In my child page just configure the Data source for each page, attached it to the gridview from the master page and the preform my task.. add, edit, delete (buttons in my master page). I am new to this and dont really have an idea of how to go about this. Some help would be appreciated. Also If someone can tell me what i am doing actually makes sense rather than adding gridviews and toolbar to each page i create. Please let me know. Thank you.
EDITED - With Answer.
Dim ContentPlaceHolder As ContentPlaceHolder
Dim gv As GridView
ContentPlaceHolder = CType(Master.FindControl("GridViewPlaceHolder"), ContentPlaceHolder)
If Not ContentPlaceHolder Is Nothing Then
gv = CType(ContentPlaceHolder.FindControl("GridView1"), GridView)
If Not gv Is Nothing Then
Dim es As EntityDataSource = EntityDataSource1
gv.DataSource = es
gv.DataBind()
End If
End If

Dim ContentPlaceHolder As ContentPlaceHolder
Dim gv As GridView
ContentPlaceHolder = CType(Master.FindControl("GridViewPlaceHolder"), ContentPlaceHolder)
If Not ContentPlaceHolder Is Nothing Then
gv = CType(ContentPlaceHolder.FindControl("GridView1"), GridView)
If Not gv Is Nothing Then
Dim es As EntityDataSource = EntityDataSource1
gv.DataSource = es
gv.DataBind()
End If
End If

Related

Child Update Panel don't to get refresh

I have problem in nested update panel. I binding the gridview by using user control and my listbox is in the child update panel while selecting the items in listbox the page is getting refresh. but I don't want to get refresh.
Here is my aspx:
<%# Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="SearchModule._Default" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
<link type="text/css" rel="stylesheet" href="Defaultstylesheet.css" />
<script src=<%--"Scripts/jquery-1.8.2.js" type="text/javascript"> </script> --%>
<%# Register TagPrefix="inc" TagName="sPager" Src="~/UserControls/SearchPager.ascx" %>
<asp:UpdatePanel ID="upseachr" runat="server" >
<ContentTemplate>
<div style="height: 50px;"></div>
<div class="searchtextbx">
<asp:TextBox ID="searchtext" runat="server"></asp:TextBox>
<asp:Button ID="Search" OnClick="Search_Click" CssClass="searchbtn" Text="Search" height="32" runat="server"> </asp:Button>
</div>
<asp:UpdateProgress ID="updatesearchpro" AssociatedUpdatePanelID="upseachr" runat="server" >
<ProgressTemplate>
<center>
<asp:Panel ID="searchpanel" runat="server">
<img alt="Processing" src="Images/359.gif" />
<br />
<asp:Label ID="panlab" runat="server" Text="Processing..."></asp:Label>
</asp:Panel>
</center>
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="updFilters" runat="server" >
<ContentTemplate>
<div class="resultpage" style="overflow-x: scroll;">
<table>
<tr>
<div class="listbox">
<asp:Label ID="headertext" runat="server" CssClass="labelresul" Font-Bold="true" Height="50" Text="Available Filter"></asp:Label>
<span style="padding-left:10px;font-weight:700;"> <asp:HiddenField runat="server" ID="hdCount" /><asp:Label ID="Total" runat="server" Height="50"></asp:Label></span><span style="padding-left:5px;font-weight:700;"><asp:Label runat="server" ID="match" Visible="false" Text="Matches"></asp:Label> <asp:Label ID="remainingcount" ForeColor="Red" Visible="false" runat="server"></asp:Label> <asp:Label ID="remaining" runat="server" ForeColor="Red" Text="Remaining" Visible="true"></asp:Label> </span>
</div>
</tr>
<tr>
<asp:ListView ID="ListView1" runat="server" OnItemDataBound="ListView1_ItemDataBound" EnableViewState="false">
<ItemTemplate>
<td>
<asp:Label ID="listheader" runat="server" Text='<%# Eval("additional_info_name1") %>'></asp:Label>
<asp:ListBox ID="results" Width="200" Visible="true" runat="server" SelectionMode="Multiple" AutoPostBack="true" OnSelectedIndexChanged="results_SelectedIndexChanged" ></asp:ListBox>
</td>
</ItemTemplate>
</asp:ListView>
</tr>
<tr>
<td class="listbox1">
<asp:Button ID="btn" runat="server" Font-Size="12" Font-Bold="true" CssClass="searchbtn" OnClick="btn_Click" Text="Apply Filter" />
</td>
</tr>
</table>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<div style="height: 40px;"></div>
<div class="resultpage" style="overflow-y: scroll;">
<asp:UpdatePanel ID="updPager" runat="server">
<ContentTemplate>
<inc:sPager ID="sPager" runat="server" OnPageIndexChanging="sPager_OnPageIndexChanging"></inc:sPager>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="updGrid" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView ID="gvResults" runat="server" AutoGenerateColumns="false" ItemStyle-VerticalAlign="Middle" AllowSorting="true"
ItemStyle-HorizontalAlign="Center" GridLines="None" CellSpacing="10" CellPadding="2" AllowCustomPaging="true" OnSorting="gvResults_Sorting"
AllowPaging="True" PageSize="20" HeaderStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Center"
HeaderStyle-CssClass="GridHeader" RowStyle-HorizontalAlign="Left" CssClass="GridStyle" >
<Columns >
<asp:TemplateField HeaderText="Stock Code" SortExpression="manufacturer_part_number" >
<ItemTemplate>
<asp:Label ID="lblFirstName" Text='<%# DataBinder.Eval(Container.DataItem, "manufacturer_part_number")%>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Manufacturer" SortExpression="Manufacturer" HeaderText="Manufacturer"></asp:BoundField>
<asp:BoundField DataField="Description" SortExpression="Description" HeaderText="Description"></asp:BoundField>
<asp:BoundField DataField="Availability" SortExpression="Availability" HeaderText="Availability"></asp:BoundField>
<asp:BoundField DataField="flag_rohs" SortExpression="flag_rohs" HeaderText="RoHS"></asp:BoundField>
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
It appears that your top-level UpdatePanel has an UpdateModeof Always (which is the default).
The MSDN documentation states:
If the UpdateMode property is set to Always, the UpdatePanel
control's content is updated on every postback that originates from
anywhere on the page. This includes asynchronous postbacks from
controls that are inside other UpdatePanel controls and postbacks
from controls that are not inside UpdatePanel controls.
You can rectify this by changing your top-level UpdatePanel control to conditional. e.g:
<asp:UpdatePanel ID="upseachr" runat="server" UpdateMode="Conditional">
Cheers

Ajaxtoolkit ConfirmButtonExtender cannot fire

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<ContentTemplate>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
Text="Button" PostBackUrl="~/testing2.aspx" />
<asp:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server"
targetControlID="Button1"
ConfirmText="Are you sure you want to click this button"
ConfirmOnFormSubmit="True" />
<asp:TextBox ID="TextBox1" runat="server" Height="25px"></asp:TextBox>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</ContentTemplate>
My ConfirmButtonExtender just not working. The website do not pop up a box for me. Do I miss somethings? My code is above.
I think you are missing OnClientCancel property. Check out the working example below.
Ensure your page is using proper master page. This is a working code.
asp:Content ContentPlaceHolderID="SampleContent" Runat="Server">
<script type='text/javascript'>
function cancelClick() {
var label = $get('ctl00_SampleContent_Label1');
label.innerHTML = 'You hit cancel in the Confirm dialog on ' + (new Date()).localeFormat("T") + '.';
}
</script>
<ajaxToolkit:ToolkitScriptManager runat="Server" EnablePartialRendering="true" ID="ScriptManager1" />
<div class="demoarea">
<div class="demoheading">ConfirmButton Demonstration</div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:LinkButton ID="LinkButton" runat="server" OnClick="Button_Click">Click Me</asp:LinkButton>
<ajaxToolkit:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server"
TargetControlID="LinkButton"
ConfirmText="Are you sure you want to click the LinkButton?"
OnClientCancel="cancelClick" />
<br />
<br />
<asp:Button ID="Button" runat="server" Text="Click Me" OnClick="Button_Click" /><br />
<ajaxToolkit:ConfirmButtonExtender ID="ConfirmButtonExtender2" runat="server"
TargetControlID="Button"
OnClientCancel="cancelClick"
DisplayModalPopupID="ModalPopupExtender1" />
<br />
<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="Button" PopupControlID="PNL" OkControlID="ButtonOk" CancelControlID="ButtonCancel" BackgroundCssClass="modalBackground" />
<asp:Panel ID="PNL" runat="server" style="display:none; width:200px; background-color:White; border-width:2px; border-color:Black; border-style:solid; padding:20px;">
Are you sure you want to click the Button?
<br /><br />
<div style="text-align:right;">
<asp:Button ID="ButtonOk" runat="server" Text="OK" />
<asp:Button ID="ButtonCancel" runat="server" Text="Cancel" />
</div>
</asp:Panel>
<asp:Label ID="Label1" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</asp:Content>

ASP.NET button link overwrites folder extension in URL

I feel almost stupid asking this because I think the answer is probably very basic. But, here it goes.
I am designing a website with a button that "rolls dice" then enables other buttons on the page (categories in my game), which ultimately, will use those buttons to go to the proper category. So, in effect, [click "roll ..."], the C# of the page (Game.aspx.cs) processes which buttons to enable, display/enable those buttons for click-ability.
My problem is this:
The page is
[domain]/UncommonSense/Game.aspx
but after I click the "roll ..." button the URL turns to
[domain]/Game.aspx#/Game.aspx
This causes a problem in the categories buttons because I need to redirect to
[domain]/UncommonSense/Question.aspx
but since Game.aspx#/ has taken the place of UncommonSense/ it fails.
CODE:
Okay, here is the code in my Game.aspx file. The button is the "ID=Roll" button listed right below "Label12." The code behind is literally right now a blank function so it is not doing anything on the C# side except posting back (apparently). However, when that button is clicked the URL goes from:
[domain]/UncommonSense/Game.aspx
to
[domain]/Game.aspx#/Game.aspx
NOTE: I just tested from a root directory and it did about the same thing:
[domain]/Game.aspx
became
[domain]/Game.aspx#/Game.aspx
Maybe this has something to do with the form?
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Game.aspx.cs" Inherits="Uncommon_Sense.Game" %>
<!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>Uncommon Sense</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
<script type="text/javascript">
</script>
</head>
<body>
<form id="form1" runat="server">
<div data-role="page">
<div data-role="header" data-theme="b">
<h1><asp:Label ID="Label1" runat="server" Text="Uncommon Sense"></asp:Label></h1>
</div>
<div data-role="content">
<h4><asp:Label ID="Label4" runat="server" Text="Game Statistics"></asp:Label></h4>
<asp:Label ID="Label11" runat="server" data-mini="true" Text=""></asp:Label>
<asp:Label ID="Label10" runat="server" data-mini="true" Text=""></asp:Label>
<h4><asp:Label ID="Label2" runat="server" Text="Game Play"></asp:Label></h4>
<asp:Button ID="Roll" runat="server" Text="Roll Dice ..." data-mini="true"
onclick="Roll_Click" />
<hr width="80%" />
<div class="ui-grid-c">
<div class="ui-block-a">
<asp:Button ID="btnShortStuffChecked" runat="server" Text="Short Stuff" data-mini="true"
data-icon="check" Enabled="False" Visible="False" />
<asp:Button ID="btnShortStuffNotChecked" runat="server" Text="Short Stuff" data-mini="true"
Enabled="False" Visible="False" onclick="btnShortStuffNotChecked_Click" /></div>
<div class="ui-block-b">
<asp:Button ID="btnWhoSaidChecked" runat="server" Text="Who Said?" data-mini="true"
data-icon="check" Enabled="False" Visible="False" />
<asp:Button ID="btnWhoSaidNotChecked" runat="server" Text="Who Said?" data-mini="true"
Enabled="False" Visible="False" /></div>
<div class="ui-block-c">
<asp:Button ID="btnCommonQuipChecked" runat="server" Text="Common Quip" data-mini="true"
data-icon="check" Enabled="False" Visible="False" />
<asp:Button ID="btnCommonQuipNotChecked" runat="server" Text="Common Quip" data-mini="true"
Enabled="False" Visible="False" /></div>
<div class="ui-block-d">
<asp:Button ID="btnRhymeTimeChecked" runat="server" Text="Rhyme Time" data-mini="true"
data-icon="check" Enabled="False" Visible="False" />
<asp:Button ID="btnRhymeTimeNotChecked" runat="server" Text="Rhyme Time" data-mini="true"
Enabled="False" Visible="False" /></div>
<div class="ui-block-a">
<asp:Button ID="btnAnythingGoesChecked" runat="server" Text="Anything Goes" data-mini="true"
data-icon="check" Enabled="False" Visible="False" />
<asp:Button ID="btnAnythingGoesNotChecked" runat="server" Text="Anything Goes" data-mini="true"
Enabled="False" Visible="False" /></div>
<div class="ui-block-b">
<asp:Button ID="btnDefineItChecked" runat="server" Text="Define It" data-mini="true"
data-icon="check" Enabled="False" Visible="False" />
<asp:Button ID="btnDefineItNotChecked" runat="server" Text="Define It" data-mini="true"
Enabled="False" Visible="False" /></div>
<div class="ui-block-c">
<asp:Button ID="btnAllAbroadChecked" runat="server" Text="All Abroad" data-mini="true"
data-icon="check" Enabled="False" Visible="False" />
<asp:Button ID="btnAllAbroadNotChecked" runat="server" Text="All Abroad" data-mini="true"
Enabled="False" Visible="False" /></div>
<div class="ui-block-d">
<asp:Button ID="btnSpellItChecked" runat="server" Text="Spell It" data-mini="true"
data-icon="check" Enabled="False" Visible="False" />
<asp:Button ID="btnSpellItNotChecked" runat="server" Text="Spell It" data-mini="true"
Enabled="False" Visible="False" /></div>
</div>
<h4><asp:Label ID="Label3" runat="server" Text="Settings"></asp:Label>
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/Question.aspx">HyperLink</asp:HyperLink>
</h4>
<label for="slider-0">Computer Difficulty:</label>
<input type="range" name="slider" id="slider-0" value="2" min="1" max="4" />
<h3><asp:Label ID="Label5" runat="server" Text="Label"></asp:Label></h3>
<asp:Button ID="ChoiceA" runat="server" Text="Button" onclick="ChoiceA_Click" />
<asp:Button ID="Button2" runat="server" Text="Button" Visible="False" />
<asp:Button ID="Button3" runat="server" Text="Button" Visible="False" />
</div>
</div>
</form>
</body>
</html>
UPDATE:
And the answer is ... JQuery Mobile!
By simply removing the reference to JQuery Mobile the problem is solved so apparently this is something in their library that changes URLs. That sucks because I liked using JQuery Mobile. Oh well, my comments will stop now on the annoyance because I am appreciative of the 99.9% of the stuff they do that helps. But, for the record...
ANY LINK will have:
linker.aspx
changed to:
linker#/linker.aspx
for some reason.

Combobox selected item is deleted once selected . Invalid Postback or Callback argument

I have four textboxes one combobox and one button ( and some other controls) in my page . Based on the values typed in the textboxes the related values are updated in the combobox. On clicking the submit button in my page It was giving the following error .
"Invalid postback or callback argument. Event validation is enabled using in configuration or in a page. For Secuity purposes,this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected . Use the ClientScriptManager.RegisterForEventsValidation method in order to register the postback or callback data for validation."
Now in the page directive I added
<%#Page EnableEentValidation="false">
When I type the values in the four textboxes the corresponding value will appear in the cobobox . But when I select that combobox value, the selected value wil be deleted . What is the reason for this ?
<%# Page Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true" CodeBehind="AddeChecklist.aspx.cs"
Inherits="LabTrack.WebApplication.Echecklist.AddeChecklist" EnableEventValidation ="false" %>
<%# Register TagPrefix="Labinal" TagName="AutoCompleteControl" Src="~/UserControls/AutoCompleteEnabledWebUserControl.ascx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<link href="../Styles/CheckListRev.css" rel="stylesheet" type="text/css" />
<!-- Style for the page -->
<link href="../Styles/AddeChecklist.css" rel="stylesheet" type="text/css" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<asp:ScriptManager ID="ScriptManager1" EnablePartialRendering="true" runat="server">
</asp:ScriptManager>
<asp:Panel ID="ErrorMessagePanel" CssClass="ErrorPanel" Visible="true" runat="server">
<div class="ErrorDiv">
<asp:BulletedList CssClass="ErrorMessage" ID="ErrorMessageBulletedList" runat="server">
</asp:BulletedList>
</div>
</asp:Panel>
<div class="PageTitle">
<asp:Label ID="PageHeaderLabel" runat="server"></asp:Label>
</div>
<div class="MainDiv">
<div style="text-align: center;">
<div class="PlaceHolder">
<table id="formTable">
<tr>
<td>
<asp:UpdatePanel runat="server" ID="updatepanelCustomer" UpdateMode="Conditional">
<ContentTemplate>
<span class="boldLabelLong">Customer:</span><br />
<asp:TextBox ID="CustomerNameTextBox" Width="200" runat="server"></asp:TextBox>
<asp:HiddenField ID="IxCustomerHiddenField" runat="server" />
<asp:Button ID="customerTriggerbutton" runat="server" Text="Button" Style="display: none;" />
</ContentTemplate>
</asp:UpdatePanel>
</td>
<td>
<asp:UpdatePanel runat="server" ID="updatepanelProgram" UpdateMode="Conditional">
<ContentTemplate>
<span class="boldLabelLong">Program:</span><br />
<asp:TextBox ID="ProgramNameTextBox" Width="200" runat="server"></asp:TextBox>
<asp:Button ID="programTriggerbutton" runat="server" Text="Button" Style="display: none;" />
<asp:HiddenField ID="IxProgramHiddenField" runat="server" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="customerTriggerbutton" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</td>
<td>
<asp:UpdatePanel runat="server" ID="updatepanelWorkPackage" UpdateMode="Conditional">
<ContentTemplate>
<span class="boldLabelLong">WorkPackage:</span><br />
<asp:TextBox ID="WorkPackageNameTextBox" Width="200" runat="server"></asp:TextBox>
<asp:HiddenField ID="IxWorkPackageHiddenField" runat="server" />
<asp:Button ID="workPackageTriggerbutton" runat="server" Text="Button" Style="display: none;" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="programTriggerbutton" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</td>
<td>
<asp:UpdatePanel runat="server" ID="updatepanelActivity" UpdateMode="Conditional">
<ContentTemplate>
<span class="boldLabelLong">Activity:</span><br />
<asp:TextBox ID="ActivityNameTextBox" Width="200" runat="server"></asp:TextBox>
<asp:HiddenField ID="IxActivityHiddenField" runat="server" />
<asp:Button ID="activityTriggerbutton" runat="server" Text="Button" Style="display: none;" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="workPackageTriggerbutton" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="activityTriggerbutton" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</td>
</tr>
</table>
</div>
<div class="PlaceHolder">
<asp:Label ID="TemplateLabel" Text="Template:" CssClass="ControlLabel" runat="server"></asp:Label>
<asp:UpdatePanel runat="server" ID="updatepanelTemplate" UpdateMode="Conditional">
<ContentTemplate>
<asp:DropDownList ID="TemplateSelectDropDownList" runat="server" Width="400" Visible="true"
AutoPostBack="true">
</asp:DropDownList>
<asp:HiddenField ID="IxTemplateHiddenField" runat="server" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="workPackageTriggerbutton" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<asp:Panel ID="SustainPanelTemplateOwner" Visible="true" runat="server">
<div>
<asp:Label ID="TemplateOwnerLabel" Text="Owner:" CssClass="ControlLabel" runat="server"></asp:Label>
<asp:TextBox ID="TemplateOwnerTextBox" CssClass="controlMargin" Width="400" runat="server"></asp:TextBox>
</div>
</asp:Panel>
<asp:HiddenField ID="IxDeliverableHiddenField" runat="server" />
<asp:HiddenField ID="IxReleaseActionHiddenField" runat="server" />
<asp:HiddenField ID="IxConfigHiddenField" runat="server" />
<asp:HiddenField ID="IxTemplateOwnerHiddenField" runat="server" />
<asp:HiddenField ID="TemplateSelectedSnameHiddenField" runat="server" />
<asp:HiddenField ID="TemplateOwnerSelectedsNameHiddenField" runat="server" />
<asp:HiddenField ID="DeliverableSelectedHiddenField" runat="server" />
<div>
<asp:Label ID="DeliverableLabel" CssClass="ControlLabel" runat="server" Text="Deliverable:"></asp:Label>
<asp:TextBox ID="DeliverableTextBox" CssClass="controlMargin" Width="400" runat="server"></asp:TextBox>
</div>
<asp:Panel ID="SustainPanelConfig" Visible="true" runat="server">
<div>
<asp:Label ID="ConfigurationLabel" runat="server" Text="Configuration:" CssClass="ControlLabel"></asp:Label>
<select id="ConfigurationSelect" class="controlMargin">
<option></option>
</select>
</div>
</asp:Panel>
<asp:Panel ID="SustainPanelRelease" Visible="true" runat="server">
<div>
<asp:Label ID="ReleaseActionLabel" CssClass="ControlLabel" runat="server" Text="Release Action:"></asp:Label>
<asp:TextBox ID="ReleaseActionTextBox" CssClass="controlMargin" Width="400" runat="server"></asp:TextBox>
</div>
</asp:Panel>
<asp:Panel ID="SustainPanel" Visible="true" runat="server">
<div class="SustainPanelControls">
<div>
<asp:Label ID="ChangeLabel" Text="Change #: " runat="server"></asp:Label>
</div>
<div>
<asp:TextBox ID="ChangeTextBox" Width="110" runat="server"></asp:TextBox>
</div>
<div>
<asp:Label ID="SupplementLabel" Text="Supplement: " runat="server"></asp:Label>
</div>
<div>
<asp:TextBox ID="SupplementTextBox" Width="80" runat="server"></asp:TextBox>
</div>
<div>
<asp:Label ID="NewWrrLabel" Text="WRR #: " runat="server"></asp:Label>
</div>
<div>
<asp:TextBox ID="NewWrrTextBox" Width="80" runat="server"></asp:TextBox>
</div>
<div>
<asp:Label ID="DddLabel" Text="3D: " runat="server"></asp:Label>
</div>
<div>
<asp:TextBox ID="DddTextBox" Width="80" runat="server"></asp:TextBox>
</div>
</div>
<div>
<table id="DesignDataTable2">
<tr>
<td>
<asp:Label ID="AllFbSheetsWrrLabel" Text="All F/B Sheets w/WRR #:" CssClass="ControlLabel" runat="server"></asp:Label>
</td>
<td>
<asp:TextBox CssClass="completeControl" ID="AllFbSheetsWrrTextBox" Width="588" Rows="2"
TextMode="MultiLine" runat="server"></asp:TextBox>
</td>
</tr>
</table>
</div>
</asp:Panel>
</div>
<div class="EditButtonGroup">
<input id="EditButton" type="button" value="Edit" class="ButtonSettings" />
<input id="RemoveButton" type="button" value="-" class="ButtonSettings" />
<input id="AddButton" type="button" value="+" class="ButtonSettings" />
</div>
</div>
<div class="ViewData">
<div class="ViewDataDiv">
<table id="DesignDataTable" class="designDataTable">
<tbody>
</tbody>
</table>
</div>
</div>
<div class="submitButtonDiv">
<asp:Button ID="SubmitButton" runat="server" Text="Button Text" class="submitButtonCreateChecklist" />
</div>
</div>
</asp:Content>
You are creating new values on the client side, and posting them back to the server.
For security reasons ASP.NET implements "event validation". When even validation is enabled, if the server creates a combo with 3 possible values, it will only accept this values on postback. If you create a different value and send it back to the server, you get the error you're referring to.
Here you have some info:
Page.EnableEventValidation Property
You can use ClientScriptManager.RegisterForEventValidation Method if you know which are the possible values generated on the client side, or disable validation completely if you don't know them in advance.
To disable validation:
You set the EnableEventValidation property by setting the enableEventValidation attribute of the # Page directive or the enableEventValidation attribute of the pages element in the Web.config file. If you set this property in code, you must set it before the page is initialized.
Sounds like an issue with Viewstate overriding the values.
Try fetching the value directly using Request.Form[Dropdown.ClientId]

Passing Value from one Gridview to another page Gridview

Hello mates i have a page View All Applicants.aspx with gridview and a link button
i want to redirect to page View Applicant Detail.aspx when i click on link button and i want to show data in gridview on View Applicant Detail.aspx page based on the previous page values.
here is the code for View All Applicants.aspx
<%# Page Language="C#" AutoEventWireup="true" CodeFile="View All Applicants.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div><center>
</center>
<center style="background-color: silver">
</center>
<center>
<strong><span style="font-size: 16pt">List of All Applicants</span></strong></center>
<center style="background-color: silver">
</center>
<center>
</center>
<center>
</center>
<center>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" AllowPaging="True"
>
<Columns>
<asp:BoundField DataField="PersonName" HeaderText="PersonName" SortExpression="PersonName" />
<asp:BoundField DataField="DegreeName" HeaderText="DegreeName" SortExpression="DegreeName" />
<asp:BoundField DataField="InstituteName" HeaderText="InstituteName" SortExpression="InstituteName" />
<asp:BoundField DataField="ExperienceYears" HeaderText="ExperienceYears" SortExpression="ExperienceYears" />
<asp:BoundField DataField="OrganizationName" HeaderText="OrganizationName" SortExpression="OrganizationName" />
<asp:BoundField DataField="Designation" HeaderText="Designation" SortExpression="Designation" />
<asp:TemplateField HeaderText="Applicant Detail">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="false" CommandName="Cancel"
OnClick="LinkButton1_Click" Text="View"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString8 %>"
ProviderName="<%$ ConnectionStrings:ConnectionString8.ProviderName %>" SelectCommand="SELECT Distinct PERSONALDETAIL.PersonName, DEGREE.DegreeName, INSTITUTE.InstituteName, EXPERIENCE.ExperienceYears, EXPERIENCE.OrganizationName, EXPERIENCE.Designation FROM EXPERIENCE, EXPERIENCE EXPERIENCE_1, PERSONALDETAIL, DEGREE, INSTITUTE WHERE EXPERIENCE.ExperienceID = EXPERIENCE_1.ExperienceID">
</asp:SqlDataSource>
</center>
<center>
</center>
<center>
</center>
<center style="background-color: silver">
</center>
</div>
</form>
</body>
</html>
and for View Applicant Detail.aspx
<%# Page Language="C#" AutoEventWireup="true" CodeFile="View Applicant Detail.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div><center>
</center>
<center style="background-color: silver">
</center>
<center>
<strong><span style="font-size: 16pt">Job Applicant Detail</span></strong></center>
<center style="background-color: silver">
</center>
<center>
</center>
<center>
</center>
<center>
</center>
<center>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ResumeID"
DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="ResumeID" HeaderText="ResumeID" InsertVisible="False"
ReadOnly="True" SortExpression="ResumeID" />
<asp:BoundField DataField="TotalExperienceYears" HeaderText="TotalExperienceYears"
SortExpression="TotalExperienceYears" />
<asp:BoundField DataField="TotalExperienceMonths" HeaderText="TotalExperienceMonths"
SortExpression="TotalExperienceMonths" />
<asp:BoundField DataField="ExperienceSummary" HeaderText="ExperienceSummary" SortExpression="ExperienceSummary" />
<asp:BoundField DataField="DetailedCVName" HeaderText="DetailedCVName" SortExpression="DetailedCVName" />
<asp:BoundField DataField="AdditionalQualification" HeaderText="AdditionalQualification"
SortExpression="AdditionalQualification" />
<asp:BoundField DataField="ExtraCurricular" HeaderText="ExtraCurricular" SortExpression="ExtraCurricular" />
<asp:BoundField DataField="Skills" HeaderText="Skills" SortExpression="Skills" />
<asp:BoundField DataField="TentativeFromDate" HeaderText="TentativeFromDate" SortExpression="TentativeFromDate" />
<asp:BoundField DataField="PageIndex" HeaderText="PageIndex" SortExpression="PageIndex" />
<asp:BoundField DataField="PersonalDetailID" HeaderText="PersonalDetailID" SortExpression="PersonalDetailID" />
<asp:BoundField DataField="DepartmentID" HeaderText="DepartmentID" SortExpression="DepartmentID" />
<asp:BoundField DataField="DesignationID" HeaderText="DesignationID" SortExpression="DesignationID" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString5 %>"
ProviderName="<%$ ConnectionStrings:ConnectionString5.ProviderName %>" SelectCommand="SELECT * FROM [RESUME]">
</asp:SqlDataSource>
</center>
<center>
</center>
<center>
</center>
<center>
</center>
<center style="background-color: silver">
</center>
</div>
</form>
</body>
</html>
You don't have to do a postbask to redirect the user to the details page, you can edit your template column to go directly to the URL of the details page along with a GET variable of the ID needed for the lookup.
<asp:TemplateField HeaderText="Applicant Detail">
<ItemTemplate>
<asp:HyperLink NavigateUrl="DetailsView.aspx?ResumeID=" + "<%# Bind("ResumeID") %>" Text="Visit W3Schools!" Target="_blank" runat="server" />
</ItemTemplate>
</asp:TemplateField>
In your Details page, do Request.QueryString("ResumeID") to get ID needed to do the lookup.

Categories

Resources