asp:RadioButtonList asp:RequiredFieldValidator Never fires the validation - asp.net

I have a webforms page (don't ask) that I am trying to get some client side validation working on, using the standard validators.
Heres some partial code
<asp:TemplateField ItemStyle-Width="50px" HeaderText="Received">
<HeaderStyle HorizontalAlign="Center" />
<ItemTemplate>
<asp:RadioButtonList ID="rbIsRecv" RepeatDirection="Horizontal"
runat="server" ValidationGroup="Curriculum">
<asp:ListItem Value="1">Yes </asp:ListItem>
<asp:ListItem Value="0">No</asp:ListItem>
</asp:RadioButtonList>
<asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator1"
ControlToValidate="rbIsRecv" Text="Required"
ValidationGroup="Curriculum" />
</ItemTemplate>
</asp:TemplateField>
<.......>
<asp:TemplateField ItemStyle-Width="50px" HeaderText="Actually Received">
<HeaderStyle HorizontalAlign="Center" />
<ItemTemplate>
<asp:TextBox ID="txtActual" runat="server" />
<asp:RequiredFieldValidator ForeColor="Red" ValidationGroup="AllValidators" runat="server"
ControlToValidate="txtActual" ErrorMessage="All values must be filled in!" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</div>
</div>
<div class="row pull-right">
<asp:Label runat="server">Employee ID: </asp:Label>
<asp:TextBox ID="txtName" runat="server" /><br />
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" CssClass="btn-primary pull-right" />
</div>
<div class="row">
<asp:RequiredFieldValidator ForeColor="Red" ValidationGroup="AllValidators" runat="server" ControlToValidate="txtName" ErrorMessage="Please enter your employee Number!" />
<asp:ValidationSummary ID="ValidationSummary1" runat="server" ValidationGroup="AllValidators"/>
</div>
So when I submit it throws and error to the Summary Control from the txtName control properly, but none of the controls within the grids....
Any ideas?

You cannot validate a RadioButtonList with a RequiredFieldValidator. You need a CustomValidator for that.
<asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="Select an option"
ClientValidationFunction="validateRadioButtonList"></asp:CustomValidator>
<script type="text/javascript">
function validateRadioButtonList(oSrc, args) {
if ($("input[name='<%= RadioButtonList1.UniqueID %>']:checked").val() == null) {
args.IsValid = false;
} else {
args.IsValid = true;
}
}
</script>

Related

page style get disturbed on ModalPopupExtender on click of button in a gridview in Update panel

I have a multiple records in a Grid view inside an update panel, Grid-view has ImageButton , onclick of this button I am displaying a ModalPopupExtender to display details of selected row. Then I close the dialog using close button.
Everything works fine until I open and close the modelpopup 10 times , after that page styles gets disturbed and page start looking ugly. When I remove the update panel then everything works fine but I need update panel for smooth UI experience.
My code is below, please help me as soon as possible , I am stuck because of this. temporarily , I am handling this by dopostback on 10th time so that user doesn't experience refresh everytime.
aspx code.
<asp:UpdatePanel ID="udpDocuments" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div class="Content">
<h1 class="HomePageHeading">Standard Operating Procedures, Guidelines, and Policies</h1>
<div class="ClearFix MarginBottom30">
<div class="SeriesInformation">
<h2>Series</h2>
<ol class="ValueList">
<li>1.000 - <span>Personnel Procedures</span>
</li>
<li>2.000 - <span>Veterinary Care/Laboratory Animal Medicine</span>
</li>
<li>3.000 - <span>Animal Husbandry/Facility Operations</span>
</li>
<li>4.000 - <span>Safety</span>
</li>
<li>5.000 - <span>Technical Procedures</span>
</li>
<li>6.000 - <span>Administration</span>
</li>
</ol>
</div>
<div class="PolicyNumberAbbr">
<h2>SOP/Policy Number Abbreviations</h2>
<ol class="ValueList">
<li>P = <span>Policy</span>
</li>
<li>G = <span>Guidelines</span>
</li>
<li>B = <span>Bethesda</span>
</li>
<li>F = <span>Frederick</span>
</li>
</ol>
</div>
</div>
<asp:Panel ID="SearchCriteria" runat="server" DefaultButton="btnSearch">
<div class="FilterWrap" style="clear: both;">
<fieldset class="FnlFieldSet">
<legend class="Clip">Filter SOP Listings</legend>
<ol class="InputFields">
<li>
<asp:Label Text="Filter by:" runat="server" ID="lblSortOrder" AssociatedControlID="ddlSortCriteria" />
<ol class="HorizontalInput">
<li>
<asp:DropDownList ID="ddlSortCriteria" runat="server" SelectMethod="Load_Filter"
OnSelectedIndexChanged="ddlSortCriteria_SelectedIndexChanged" AutoPostBack="true"
AppendDataBoundItems="true" DataTextField="Value" DataValueField="Key">
</asp:DropDownList>
<asp:DropDownList ID="ddlCampus" Visible="false" runat="server" SelectMethod="Load_Campus" AppendDataBoundItems="true" DataTextField="value" DataValueField="key">
<asp:ListItem Text="[Select]" Value="0" />
</asp:DropDownList>
<asp:DropDownList ID="ddlSeries" Visible="false" runat="server" SelectMethod="Load_Series" AppendDataBoundItems="true" DataTextField="Name" DataValueField="Id">
<asp:ListItem Text="[Select]" Value="0" />
</asp:DropDownList>
<dms:WatermarkTextBox ID="wmTitle" runat="server" MaxLength="60" Columns="30" WatermarkText="Title" />
</li>
<li>
<span class="InputButtonWrapper HasIcon SearchIcon">
<asp:Button ID="btnSearch" Text="Search" OnClick="btnSearch_Click" runat="server" />
</span>
<asp:Button ID="btnReset" Text="Reset" OnClick="btnReset_Click" runat="server" />
</li>
</ol>
</li>
</ol>
</fieldset>
</div>
</asp:Panel>
<dms:GridView ID="gvSOPDetails" runat="server" AllowPaging="true" PageSize="50" AllowSorting="true" DataKeyNames="Id"
AutoGenerateColumns="False" SelectMethod="SopListingGrid_GetItem" Width="100%"
OnRowCommand="gvSOPDetails_RowCommand" OnRowDataBound="gvSOPDetails_RowDataBound"
ItemType="Dms.Css.Ncif.Lasp.SopTraining.Biz.LaspSopTraining.Sop">
<Columns>
<asp:TemplateField HeaderText="SOP/Policy#" SortExpression="Number">
<ItemTemplate>
<asp:Label ID="lblNumber" runat="server" Text='<%# Item.Number %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Title" SortExpression="Title">
<ItemTemplate>
<asp:HyperLink runat="server" ID="lnkDeleteResponderIssueImage" NavigateUrl="<%# Item.MainFileAttachment==null?string.Empty:Item.MainFileAttachment.ResourceUrl %>" CssClass="FileDownloadLink" Target="_blank" Text='<%# Item.Title %>'></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Revision Number" SortExpression="RevisionNumber">
<ItemTemplate>
<asp:Label ID="lblRevisionNumber" runat="server" Text='<%# Item.RevisionNumber %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Revision Date" SortExpression="RevisionDate">
<ItemTemplate>
<%# string.Format("{0:d}", Item.RevisionDate)%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Effective Date" SortExpression="EffectiveDate">
<ItemTemplate>
<%# string.Format("{0:d}", Item.EffectiveDate)%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Campus" SortExpression="LocationId">
<ItemTemplate>
<%# Dms.Framework.Extensions.EnumExtensions.Description(Item.LocationId) %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Attachments" ItemStyle-HorizontalAlign="center">
<ItemTemplate>
<asp:ImageButton ID="imgBtnViewAttachment" runat="server" CommandName="ViewAttachment"
Enabled="true" CommandArgument='<%# Item.Id %>'
Text="Delete" ImageUrl="~/Media/Images/modal-open-icon.png" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
No records match your search criteria.
</EmptyDataTemplate>
</dms:GridView>
</div>
<div>
<%-- OnCancelScript="__doPostBack('Ok','')" is added to fix the issue when you open the model popup 10 times and on 11th time it mashed up the UI--%>
<asp:Button ID="btnShowModelPopup" runat="server" Text="Button" CssClass="HideModelPopupButton" />
<asp:HiddenField ID="hfSelectedSOP" runat="server" />
<cc1:ModalPopupExtender ID="mpeAttachments" runat="server"
CancelControlID="imgBtnPopupClose"
TargetControlID="btnShowModelPopup" PopupControlID="pnlAttachmentsForSelectedSOP"
PopupDragHandleControlID="PopupHeader" Drag="true"
OnCancelScript="OnCloseButtonClientClick()"
RepositionMode="RepositionOnWindowResizeAndScroll"
BackgroundCssClass="ModalPopupBG">
</cc1:ModalPopupExtender>
<asp:Panel ID="pnlAttachmentsForSelectedSOP" Style="display: none" runat="server">
<div>
<div class="PopupHeader">
<asp:ImageButton ID="imgBtnPopupClose" CssClass="ModalCloseButton" runat="server" ImageUrl="~/Media/Images/modal-close-icon.png" />
</div>
<div class="PopupBody">
<div class="PopupTitle">
<asp:Label ID="lblTitle" runat="server"></asp:Label>
<span>attachments</span>
</div>
<asp:Panel ID="pnlSupportingAttachments" runat="server">
<ul>
<asp:ListView runat="server" ID="lvSupportingAttachments" DataKeyNames="Id" ItemType="Dms.Css.Ncif.Lasp.SopTraining.Biz.LaspSopTraining.Attachment"
SelectMethod="LoadModelPopupAttachment">
<ItemTemplate>
<li>
<span>
<asp:HyperLink runat="server" ID="lnkDeleteResponderIssueImage" NavigateUrl="<%# Item.ResourceUrl %>" CssClass="FileDownloadLink" Target="_blank" Text='<%# Item.FileName %>'></asp:HyperLink>
</span>
</li>
</ItemTemplate>
</asp:ListView>
</ul>
</asp:Panel>
</div>
</div>
</asp:Panel>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<asp:HiddenField ID="closeCount" ClientIDMode="Static" Value="0" runat="server" />
<script type="text/javascript">
var count = 0;
function OnCloseButtonClientClick() {
if (count == 8) {
//__doPostBack('Ok', '');
count = 0;
}
else {
count = count + 1;
}
return false;
}
</script>
protected void gvSOPDetails_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "ViewAttachment")
{
hfSelectedSOP.Value = (string)e.CommandArgument;
mpeAttachments.TargetControlID = "btnShowModelPopup";
lvSupportingAttachments.DataBind();
mpeAttachments.Show();
}
}
Got solution, It is only about moving code around update panel:
ASPX code:
<dms:GridView ID="gvSOPDetails" runat="server" AllowPaging="true" PageSize="50" AllowSorting="true" DataKeyNames="Id"
AutoGenerateColumns="False" SelectMethod="SopListingGrid_GetItem" Width="100%"
OnRowCommand="gvSOPDetails_RowCommand" OnRowDataBound="gvSOPDetails_RowDataBound"
ItemType="Dms.Css.Ncif.Lasp.SopTraining.Biz.LaspSopTraining.Sop">
<Columns>
<asp:TemplateField HeaderText="SOP/Policy#" SortExpression="Number">
<ItemTemplate>
<asp:Label ID="lblNumber" runat="server" Text='<%# Item.Number %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Attachments" ItemStyle-HorizontalAlign="center">
<ItemTemplate>
<asp:ImageButton ID="imgBtnViewAttachment" runat="server" CommandName="ViewAttachment"
Enabled="true" CommandArgument='<%# Item.Id %>'
Text="Delete" ImageUrl="~/Media/Images/modal-open-icon.png" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
No records match your search criteria.
</EmptyDataTemplate>
</dms:GridView>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<asp:Panel ID="pnlAttachmentsForSelectedSOP" Style="display: none" runat="server">
<div>
<div class="PopupHeader">
<asp:ImageButton ID="imgBtnPopupClose" CssClass="ModalCloseButton" runat="server" ImageUrl="~/Media/Images/modal-close-icon.png" />
</div>
<div class="PopupBody">
<div class="PopupTitle">
<asp:Label ID="lblTitle" runat="server"></asp:Label>
<span>attachments</span>
</div>
<asp:UpdatePanel ID="upAttachmentList" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel ID="pnlSupportingAttachments" runat="server">
<ul>
<asp:ListView runat="server" ID="lvSupportingAttachments" DataKeyNames="Id" ItemType="Dms.Css.Ncif.Lasp.SopTraining.Biz.LaspSopTraining.Attachment"
SelectMethod="LoadModelPopupAttachment">
<ItemTemplate>
<li>
<span>
<asp:HyperLink runat="server" ID="lnkDeleteResponderIssueImage" NavigateUrl="<%# Item.ResourceUrl %>" CssClass="FileDownloadLink" Target="_blank" Text='<%# Item.FileName %>'></asp:HyperLink>
</span>
</li>
</ItemTemplate>
</asp:ListView>
</ul>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
</asp:Panel>
<asp:Button ID="btnShowModelPopup" runat="server" Text="Button" CssClass="HideModelPopupButton" />
<asp:HiddenField ID="hfSelectedSOP" runat="server" />
<cc1:ModalPopupExtender ID="mpeAttachments" runat="server"
CancelControlID="imgBtnPopupClose"
TargetControlID="btnShowModelPopup" PopupControlID="pnlAttachmentsForSelectedSOP"
PopupDragHandleControlID="PopupHeader" Drag="true"
RepositionMode="RepositionOnWindowResizeAndScroll"
BackgroundCssClass="ModalPopupBG">
</cc1:ModalPopupExtender>
ASPX.cs: code:
protected void gvSOPDetails_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "ViewAttachment")
{
hfSelectedSOP.Value = (string)e.CommandArgument;
mpeAttachments.TargetControlID = "btnShowModelPopup";
lvSupportingAttachments.DataBind();
upAttachmentList.Update();
mpeAttachments.Show();
}
}

modal popup not showing from code behind

<asp:UpdatePanel ID="updtpnlacademic" runat="server">
<ContentTemplate>
<td>
<asp:GridView ID="gdvwAcademic1" runat="server" OnRowCommand="gdvwAcademic1_RowCommand" OnRowDeleting="gdvwAcademic1_RowDeleting" CellPadding="4" ForeColor="#333333" GridLines="None" Width="100%" AllowSorting="True" AutoGenerateColumns="False" HorizontalAlign="Center">
<Columns>
....Other column fields
<asp:TemplateField HeaderText="Delete" ItemStyle-HorizontalAlign="Center" ShowHeader="false">
<ItemTemplate>
<asp:ImageButton ID="imgbtnacademicdelete" CommandName="Delete" OnClick="imgbtnacademicdelete_Click" CommandArgument='<%# ((GridViewRow)Container).RowIndex %>' ToolTip="Delete" runat="server" ImageAlign="Top" ImageUrl="~/Images/delete.png" Width="30" Height="25"/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:Button ID="btndummy" runat="server" Visible="false" />
<cc1:ModalPopupExtender ID="mpacademic" runat="server" TargetControlID="btndummy" PopupControlID="Panel2" CancelControlID="btnacademicClose" BackgroundCssClass="modalBackground">
</cc1:ModalPopupExtender>
<asp:Panel ID="Panel2" runat="server" CssClass="modalPopup" HorizontalAlign="Center" style = "display:none">
<span style="color:white; font-family:'Bookman Old Style'; font-weight:bold;">Really Want To Delete This Record...!</span><br /><br /><br /><br />
<asp:Button ID="btnconfirmacademicdelete" OnClick="btnconfirmacademicdelete_Click" CssClass="BStyle" Font-Bold="true" runat="server" Text="Yes" />
<asp:Button ID="btnacademicClose" Font-Bold="true" runat="server" CssClass="BStyle" Text="Cancel" />
</asp:Panel>
</td>
</ContentTemplate>
</asp:UpdatePanel>
And following code as in the code behind ....
protected void gdvwAcademic1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
mpacademic.Show();
//System.Windows.Forms.MessageBox.Show("RowDeleting clicked after this modal popup should be displayed.....!");
}
It only show messagebox on event if uncomment messagebox but not showing modal popup
<cc1:ModalPopupExtender ID="mpacademic" runat="server" TargetControlID="btndummy" PopupControlID="Panel2" CancelControlID="btnacademicClose" BackgroundCssClass="modalBackground">
</cc1:ModalPopupExtender>
The TargetControlID property is set to btndummy and
<asp:Button ID="btndummy" runat="server" Visible="false" />
btndummy is not rendering since Visible property is set to false.
Try to replace
<asp:Button ID="btndummy" runat="server" Visible="false" />
With
<asp:Button ID="btndummy" runat="server" style="display:none" />

Ajax for asp.net form view

Inside form view I have drop down list on selected index change I have text box appearing.
Now I want to keep both these drop down and Text box inside Ajax update panel. Upon click button out side update panel I want to save these two fields as well.
Any help Much appreciated.
Here aspx code
<asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' />
<br />
<asp:DropDownList ID="ddlLName"
runat="server" ValidationGroup="VG1" SelectedValue='<%# Bind("LNAMEIFYES") %>' OnSelectedIndexChanged="ddlLName_SelectedIndexChanged" AutoPostBack="True">
<asp:ListItem Value="">Please select...</asp:ListItem>
<asp:ListItem Value="1">Yes</asp:ListItem>
<asp:ListItem Value="2">No</asp:ListItem>
</asp:DropDownList>
<br />
<asp:Panel ID="pnlLNAme" runat="server" Visible="false">
LName:
<asp:TextBox ID="LNameTextBox" runat="server" Text='<%# Bind("LName") %>' />
<br />
</asp:Panel>
Code Behind
protected void ddlLName_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList ddlLName = (DropDownList)FormView1.FindControl("ddlLName");
if (ddlLName.SelectedValue == "1")
{
Panel pnlLNAme = (Panel)FormView1.FindControl("pnlLNAme");
pnlLNAme.Visible = true;
}
else
{
Panel pnlLNAme = (Panel)FormView1.FindControl("pnlLNAme");
pnlLNAme.Visible = false;
}
}
I solved the problem by using by using two update panals, using trigger in one of the update panal.
<EditItemTemplate>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
ID:
<asp:Label ID="IDLabel1" runat="server" Text='<%# Eval("ID") %>' />
<br />
Name:
<asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' />
<br />
<asp:DropDownList ID="ddlLName"
runat="server" ValidationGroup="VG1" SelectedValue='<%# Bind("LNAMEIFYES") %>' OnSelectedIndexChanged="ddlLName_SelectedIndexChanged" AutoPostBack="True">
<asp:ListItem Value="">Please select...</asp:ListItem>
<asp:ListItem Value="1">Yes</asp:ListItem>
<asp:ListItem Value="2">No</asp:ListItem>
</asp:DropDownList>
<br />
<asp:Panel ID="pnlLNAme" runat="server" Visible="false">
LName:
<asp:TextBox ID="LNameTextBox" runat="server" Text='<%# Bind("LName") %>' />
<br />
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
Salary:
<asp:TextBox ID="SalaryTextBox" runat="server" Text='<%# Bind("Salary") %>' />
<br />
IsActive:
<asp:CheckBox ID="IsActiveCheckBox" runat="server" Checked='<%# Bind("IsActive") %>' />
<br />
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update" Text="Update" />
<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="UpdateButton" EventName="Click_Enent" />
</Triggers>
</asp:UpdatePanel>
</EditItemTemplate>

How do i get asp:Panel Default Button to fire button click event?

I have three asp net text boxes that will contain search criteria for searching a table. I would like the search to work like Google. When the enter key is pressed to have the click event on the "Enter" button fire. The click event never fires. What can I do to get it to fire?
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="WebCategoryGenerateEdit.ascx.cs"
Inherits="EPPA.Controls.WebCategoryGenerateEdit" ClientIDMode="Static" %>
<script src="/Scripts/jquery-1.8.3.js" type="text/javascript"></script>
<script type="text/javascript">
// debugger;
function pageLoad() {
var gvCategoryMessage = $("#<%=GVCategoryMessage.ClientID %>").html
if (gvCategoryMessage.length != 0) {
$("#<%=GVParentCategoryLinkTitle.ClientID %>").keydown(function () {
$("#<%=GVCategoryMessage.ClientID %>").html("");
})
$("#<%=GVCategoryLinkTitle.ClientID %>").keydown(function () {
$("#<%=GVCategoryMessage.ClientID %>").html("");
})
}
}
</script>
<asp:ScriptManager runat="server" />
<asp:MultiView ID="Multiview1" runat="server" ActiveViewIndex="0">
<asp:View ID="SearchView" runat="server">
<asp:Table ID="TableSV1" runat="server">
<asp:TableRow ID="TableRowSV1" runat="server">
<asp:TableCell ID="TableCellSV1" runat="server">
<asp:Label ID="LabelSV1" runat="server" SkinID="SearchTextLabel"
Text="CB or CJ" CssClass="searchTextLabel_Division"/>
</asp:TableCell>
<asp:TableCell ID="TableCellSV2" runat="server">
<asp:Label ID="LabelSV2" runat="server"
SkinID="SearchTextLabel" Text="Parent Category Link Title"
CssClass="searchTextLabel_ParentCategoryLink" />
</asp:TableCell>
<asp:TableCell ID="TableCellSV3" runat="server">
<asp:Label ID="LabelSV3" runat="server"
SkinID="SearchTextLabel"
Text="Category Link Title" CssClass="searchTextLabel_CategoryLink" />
</asp:TableCell>
<asp:TableCell ID="TableCellSV4" runat="server">
<asp:Label ID="Label1" runat="server"
SkinID="SearchTextLabel"
Text="Category ID" CssClass="searchTextLabel_CategoryID" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow ID="SVTableRowSV2" runat="server">
<asp:TableCell ID="TableCellSV5" runat="server">
<asp:DropDownList ID="SVDivisionDDL" runat="server"
OnSelectedIndexChanged="SVDivisionDDL_SelectedIndexChanged" AutoPostBack="true" >
<asp:ListItem Value="CB">CB</asp:ListItem>
<asp:ListItem Value="CJ">CJ</asp:ListItem>
</asp:DropDownList>
</asp:TableCell>
<asp:TableCell ID="TableCellSV6" runat="server" >
<asp:panel ID="SVPCLTContainer" runat="server"
DefaultButton="SV6EnterButton">
<asp:TextBox ID="SVParentCategoryLinkTitle" runat="server"
SkinID="SearchTextBox"
CssClass="searchTextBox_ParentCategoryLink" />
<asp:Button ID="SV6EnterButton" runat="server" Visible="false"
Text="Enter" OnClick="EnterKeyPressed_Click" />
</asp:panel>
</asp:TableCell>
<asp:TableCell ID="TableCellSV7" runat="server" >
<asp:TextBox ID="SVCategoryLinkTitle"
runat="server" SkinID="SearchTextBox"
CssClass="searchTextBox_CategoryLink" />
</asp:TableCell>
<asp:TableCell ID="TableCellSV8" runat="server" >
<asp:TextBox ID="SVCategoryID" runat="server"
SkinID="SearchTextBox"
CssClass="searchTextBox_CategoryID" />
</asp:TableCell>
</asp:TableRow>
</asp:Table>
<asp:Button ID="SVGenNewButton" runat="server" Text="Generate New Category ID"
OnClick="SVGenerateNewButton_Click" />
<asp:Button ID="SVDeleteButton" runat="server" Text="Delete Checked items"
OnClick="SVDeleteButton_Click" />
<div style="width:618px; overflow-x:no-display; overflow-y:auto; max-height:392px;
padding-top:2px; ">
<asp:GridView ID="gvWebCategoryID" runat="server" AutoGenerateColumns="False"
SkinID="gridViewSkin" OnRowDeleting="gvWebCategoryID_RowDeleting" >
<Columns>
<asp:TemplateField HeaderText="Edit">
<ItemTemplate>
<asp:Button ID="SVgridViewEditButton" runat="server"
OnClick="gvWeCategoryIDEditButton_Click" Text="Edit" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Delete">
<ItemTemplate>
<asp:CheckBox ID="Checkbox1" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Division" HeaderText="CB or CJ"
Visible="true" />
<asp:BoundField DataField="ParentCategoryLinkTitle" HeaderText="Parent
Category Link Title" />
<asp:BoundField DataField="CategoryLinkTitle" HeaderText="Category
Link Title" />
<asp:BoundField DataField="CategoryID" HeaderText="Category ID" />
<asp:TemplateField HeaderText="Error Message" Visible="false" >
<ItemTemplate>
<asp:Label ID="ErrorMessage" runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</asp:View>
</asp:MultiView>
and here is the behind code method:
protected void EnterKeyPressed_Click(object sender, EventArgs e)
{
ReloadData();
this.Multiview1.ActiveViewIndex = 0;
}
At a quick glance, have you tried removing the return false here:
$("#<%=SVParentCategoryLinkTitle.ClientID %>").keydown(function (e) {
if (e.which == 13) {
__doPostBack("#<%=EnterKeyPressed.UniqueID %>", "");
return false;
}
})
check out this question and answer, if it helps: Default button not working in asp.net panel
the DefaultButton is used to capture the Enter key press if the focus is already inside the panel, for example you must have moved the focus to an input field like the text boxes inside the panel. if the focus is not there it won't work.

Button Outside Gridview not firing once click on Edit button of gridview

I have a gridview and i have two buttons edit and delete.Once i click on edit button, i take the values and put those in textboxes outside grid and visible update and cancel button. but that does not fires..
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:Panel ID="pnladdproduct" runat="server">
<div class="mws-form-col-1-8">
<asp:Label ID="Label11" runat="server" AssociatedControlID="btnAddProduct"> </asp:Label>
<div class="mws-form-item large">
<asp:Button ID="btnAddProduct" ValidationGroup="grpProduct" runat="server" CssClass="mws-button red" Text="Add" OnClick="btnAddProduct_Click" />
</div>
</div>
</asp:Panel>
<asp:Panel ID="pnlUpdateProduct" runat="server">
<div class="mws-form-col-1-8">
<asp:Label ID="Label12" runat="server" AssociatedControlID="btnUpdateProduct"> </asp:Label>
<div class="mws-form-item large">
<asp:Button ID="btnUpdateProduct" runat="server" CausesValidation="False" CssClass="mws-button blue" Text="Update" OnClick="btnUpdateProduct_Click" />
</div>
</div>
</asp:Panel>
<asp:Panel ID="pnlCancel" runat="server">
<div class="mws-form-col-1-8">
<asp:Label ID="Label13" runat="server" AssociatedControlID="btnCancelUpdate"> </asp:Label>
<div class="mws-form-item large">
<asp:Button ID="btnCancelUpdate" CausesValidation="False" runat="server" CssClass="mws-button gray" Text="Cancel" OnClick="btnCancelUpdate_Click" />
</div>
</div>
</asp:Panel>
<div class="mws-form-col-8-8">
<asp:GridView ID="grdProduct" ShowHeaderWhenEmpty="True" CssClass="mGrid" runat="server" AutoGenerateColumns="False" AllowPaging="True" PagerStyle-CssClass="pgr" AlternatingRowStyle-CssClass="alt" OnPageIndexChanging="grdProduct_PageIndexChanging" OnRowDeleting="grdProduct_RowDeleting" OnRowEditing="grdProduct_RowEditing">
<Columns>
<asp:BoundField DataField="Name" HeaderText="Product" SortExpression="Product" />
<asp:BoundField DataField="Quantity" HeaderText="Quantity" SortExpression="Quantity" />
<asp:BoundField DataField="Rate" HeaderText="Rate" SortExpression="Rate" />
<asp:BoundField DataField="Amount" HeaderText="Amount" SortExpression="Amount" />
<asp:ButtonField ButtonType="Image" CommandName="Edit" HeaderText="Edit" ImageUrl="~/css/icons/16/edit.png" ShowHeader="True" Text="Edit" />
<asp:ButtonField ButtonType="Image" CommandName="Delete" HeaderText="Delete" ImageUrl="~/css/icons/16/delete.png" ShowHeader="True" Text="Delete" />
<asp:TemplateField HeaderText="HiddenColumn">
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<asp:HiddenField ID="hdfProductID" runat="server" Value='<%# Bind("ProID") %>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
No Products Added !!
</EmptyDataTemplate>
</asp:GridView>
<div class="mws-form-row inline">
<asp:Label ID="Label15" runat="server" AssociatedControlID="txtQuantity">Total Amount</asp:Label>
<div class="mws-form-item medium">
<asp:TextBox ID="txtTotalAmount" BackColor="Beige" BorderColor="red" ReadOnly="True" CssClass="mws-textinput" runat="server"></asp:TextBox>
</div>
</div>
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnUpdateProduct" EventName="Click"/>
<asp:PostBackTrigger ControlID="btnCancelUpdate" />
</Triggers>
</asp:UpdatePanel>
Server side Code..
protected void grdProduct_RowEditing(object sender, GridViewEditEventArgs e)
{
Session["proID"] = StepGetHiddenValuesFromGridControl(e.NewEditIndex);
txtQuantity.Text = grdProduct.Rows[e.NewEditIndex].Cells[1].Text;
txtRate.Text = grdProduct.Rows[e.NewEditIndex].Cells[2].Text;
txtAmount.Text = grdProduct.Rows[e.NewEditIndex].Cells[3].Text;
txtQuantity.BackColor = Color.Beige;
txtRate.BackColor = Color.Beige;
txtAmount.BackColor = Color.Beige;
//pnladdproduct.Visible = false;
//pnlUpdateProduct.Visible = true;
//pnlCancel.Visible = true;
}
protected void btnUpdateProduct_Click(object sender, EventArgs e)
{
// this code not firing
}
I don't think there's a need for triggers.

Resources