I have two gridView: grvHeadline and gdvNotification, gdvNotification is load data by selected item of grvHeadline .
When page load: data of gdvNotification is load by first item of grvHeadline.
My problem is:
The page load is first: if gdvNotification has paging (1,2,3,...), when i click paging in gdvNotification, it not run. Page is reload but page index is 0.
When i select other item in grvHeadline and reselect first item, then click paging in gdvNotification, it run, page index was changed.
I was debug: When the page is load first time: I click to page index in gdvNotification then pageload() was called with IsPostBack=True, but not call to event gdvNotification_PageIndexChanging of gdvNotification.
Here is my code:
protected void gdvNotification_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
logger.Debug("Gridview Headline page index changing .");
gdvNotification.PageIndex = e.NewPageIndex;
HeadlineSelected(hdfNotificationIdSelected.Value, e.NewPageIndex);
//gdvNotification.DataBind();
lbPageIndex.Text = (e.NewPageIndex + 1).ToString(CultureInfo.InvariantCulture);
}
And
private void HeadlineSelected(string notificationIdSelected, int index)
{
logger.Debug("Head line selected");
GetDataFromSessionAndCache();
IList<InformationEntity> infoNotificationList = new List<InformationEntity>();
if (string.IsNullOrEmpty(notificationIdSelected))
{
//Clear
IList<InformationEntity> data = new List<InformationEntity>()
{
new InformationEntity()
{
AuthorName = string.Empty,
Contents = string.Empty,
BulletinDateFrom = null,
BulletinDateTo = null,
Id = string.Empty,
Subject = string.Empty,
}
};
gdvNotification.DataSource = data;
gdvNotification.DataBind();
pnPageIndex.Visible = false;
btnEditNotification.Enabled = false;
}
else
{
infoNotificationList = MasterDataHelper.GetInformationByHighOrderId(notificationIdSelected);
logger.Debug("Notification list not null");
if (infoNotificationList != null)
{
if (infoNotificationList.Count == 0)
{
pnPageIndex.Visible = false;
hdfNotificationId.Value = string.Empty;
btnEditNotification.Enabled = false;
}
else
{
if (infoNotificationList.Count == 1)
{
fakepanel.Visible = true;
}
else
{
fakepanel.Visible = false;
}
if (base.IsPermission(PERMISSION_INFORMATION_FOLLOWUP))
{
btnEditNotification.Enabled = true;
}
pnPageIndex.Visible = true;
gdvNotification.PageIndex = index;
hdfNotificationId.Value = infoNotificationList[index].Id;
gdvNotification.DataSource = infoNotificationList;
gdvNotification.DataBind();
}
logger.Debug("Set value for label total page");
lblTotalPage.Text = gdvNotification.PageCount.ToString(CultureInfo.InvariantCulture);
lbPageIndex.Text = gdvNotification.PageCount == 0
? gdvNotification.PageCount.ToString(CultureInfo.InvariantCulture)
: (gdvNotification.PageIndex + 1).ToString(CultureInfo.InvariantCulture);
lbTotal.Text = infoNotificationList.Count().ToString(CultureInfo.InvariantCulture);
}
}
}
Update code in view *.aspx.
<table style="padding-top: 25px; padding-bottom: 25px; table-layout: fixed" width="100%">
<tr>
<td style="width: 49%" class="Top">
<table class="Master" style="width: 100%; height: 35px; border-spacing: 2px 0px">
<tr style="padding: 0px 0px 0px 0px; margin: 0px 0px 0px 0px;">
<td class="BasicValue" style="width: 100%; padding: 0px 0px 0px 0px; margin: 0px 0px 0px 0px;">
<asp:Panel ID="Panel2" runat="server" DefaultButton="btnSearch">
<asp:TextBox ID="txtFuzzySearch" runat="server" Style="width: 76%; height: 25px; text-align: left;
float: left; border-style: double; border-color: Gray;" />
<asp:Label ID="label" runat="server" Text="※あいまい検索" Width="20%" Style="text-align: center;
vertical-align: middle; margin-top: 5px;" />
<asp:Button ID="btnSearch" runat="server" Text="Button" Style="display: none" OnClick="btnSearch_Click" />
</asp:Panel>
</td>
</tr>
</table>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Panel ID="panelContainer" runat="server" Width="100%" Height="582px" Style="margin-top: 0px;overflow-y: auto">
<asp:HiddenField ID="hdfNotificationIdSelected" runat="server" Value="" />
<asp:GridView ID="grvHeadline" runat="server" AutoGenerateColumns="False" Style="width: 100%"
BorderWidth="0px" CellSpacing="2" CellPadding="10" GridLines="None" ShowHeader="false"
OnSelectedIndexChanged="grvHeadline_SelectedIndexChanged" OnRowDataBound="grvHeadline_RowDataBound">
<HeaderStyle CssClass="BasicColumnTitle" />
<AlternatingRowStyle CssClass="RowStyleEven" />
<RowStyle CssClass="RowStyleOdd" />
<SelectedRowStyle CssClass="RowStyleHi heallineSelected" />
<Columns>
<asp:TemplateField>
<HeaderStyle Width="10%" />
<ItemStyle Width="80%" />
<ItemTemplate>
<table style="border-spacing: 0px">
<tr>
<td>
<asp:Image ID="Image6" runat="server" ImageAlign="Left" Style="display: none" ImageUrl="../img/triangle-on.png" />
<asp:Image ID="Image1" runat="server" ImageAlign="Left" Style="display: none" ImageUrl="../img/triangle-off.png" />
<asp:Image ID="Image4" runat="server" Visible='<% #int.Parse(Eval("ThreadQty").ToString()) < 2%>'
ImageAlign="Left" ImageUrl="../img/Doc1.png" />
<asp:Image ID="Image5" runat="server" Visible='<% #int.Parse(Eval("ThreadQty").ToString())>=2%>'
ImageAlign="Left" ImageUrl="../img/Doc2.png" />
</td>
<td>
<asp:Label CssClass="bold" Style="resize: none; width: 100%; margin-left: 5px; vertical-align: bottom;
text-align: justify" ID="txt1" Text='<%#DevideString(HttpUtility.HtmlEncode(Eval("Subject")), 35) %>' runat="server">
</asp:Label><br />
<asp:Label CssClass="bold" Style="resize: none; margin-left: 5px; vertical-align: bottom; text-align: justify;"
ID="txt2" Text='<%#DevideString(HttpUtility.HtmlEncode(Eval("AuthorName")), 35) %>' runat="server" />
</td>
</tr>
</table>
<asp:HiddenField ID="hdfSelectedId" runat="server" Value='<% #Eval("Id")%>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderStyle Width="3%" />
<ItemStyle Width="20%" VerticalAlign="Top" CssClass="position" />
<ItemTemplate>
<table style="border-spacing: 0px; height: 100%;" width="100%">
<tr>
<td class="Top Left" style="height: auto;">
<asp:Image ID="Image3" runat="server" CssClass="Top Left" Visible='<%# ShowImgUpScreen(DateTime.Parse(Eval("BulletinDateFrom").ToString()),Eval("ThreadQty").ToString()) %>'
ImageAlign="Left" Style="vertical-align: top;" ImageUrl="~/img/Up1.png" />
<asp:Image ID="Image7" runat="server" CssClass="Top Left" Visible='<%# ShowImgNewScreen(DateTime.Parse(Eval("BulletinDateFrom").ToString()),Eval("ThreadQty").ToString()) %>'
ImageAlign="Left" Style="vertical-align: top;" ImageUrl="~/img/New2.png" />
</td>
</tr>
</table>
<asp:Label ID="Label4" runat="server" CssClass="Right Bottom" Text='<%#CheckDateTime((DateTime)Eval("BulletinDateFrom"))%>'
Style="float: right; position: absolute; bottom: 3px; right: 3px" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</asp:Panel>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="grvHeadline" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
<table class="BasicValue" style="width: 100%; margin-bottom: -58px; margin-top: 43.5px">
<tr style="padding: 0px 0px 0px 0px; margin: 100px 0px 0px 0px;">
<td class="BasicValue" style="padding: 5px 10px 5px 10px">
<asp:Button ID="btnNewHeadline" class="ButtonSchedule" runat="server" Text="ヘッドラインの新親追加"
Height="100%" Style="text-align: center; float: right; margin: 0px 5px 0px 0px;"
Width="165px" OnClick="btnNewHeadlineRegist_Click" />
</td>
</tr>
</table>
</td>
<td style="width: 1%;" class="Center">
<div class="verticalLine" style="background-color: #C5C5CA; text-align: center; height: 696px;
width: 4px; margin-left: 48%">
</div>
</td>
<td style="width: 49%; position: relative" class="Top">
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:HiddenField ID="hdfNotificationId" runat="server" />
<asp:GridView ID="gdvNotification" runat="server" AutoGenerateColumns="False" Style="width: 100%;"
BorderWidth="0px" CellSpacing="0" CellPadding="0" GridLines="None" PageSize="1"
AllowPaging="True" ShowHeader="false" OnPageIndexChanging="gdvNotification_PageIndexChanging">
<HeaderStyle CssClass="BasicColumnTitle" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Panel ID="panel1" runat="server" Width="100%" Height="618" ScrollBars="Vertical">
<table style="width: 100%;">
<tbody>
<tr style="height: 40px">
<td class="BasicValue" style="vertical-align: bottom;padding-left:2em">
<div>
<asp:Label ID="lblhead" CssClass="bold" runat="server" Text='<% #Eval("Subject")%>' Style=" font-weight: bold"></asp:Label>
</div>
</td>
</tr>
<tr style="height: 40px">
<td class=" BasicValue" style="vertical-align: bottom ;padding-left: 2em;">
<div>
<asp:Label ID="Label2" runat="server" Style=" font-weight: bold" Text='<% #Eval("AuthorName")%>'></asp:Label><asp:Label
ID="Label3" runat="server" Style="float: right" Text='<%# string.Format("{0:yyyy/MM/dd hh:mm}",Eval("BulletinDateFrom"))%>'></asp:Label></div>
</td>
</tr>
<tr style="height: 40px">
<td class="BasicValue" style="vertical-align: bottom">
<div>
<asp:Label ID="lblSection" runat="server" Style="padding-left: 2em;" Text='<%# GetSectionName(Eval("Id").ToString())%>'></asp:Label>
</div>
</tr>
<tr style="height: 497px;">
<td class="BasicValue" style="text-align: left; vertical-align: top; padding-left:2em ">
<asp:Label ID="lblContent" runat="server"
Text='<% #Eval("Contents")%>'></asp:Label>
</td>
</tr>
</tbody>
</table>
</asp:Panel>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:Panel runat="server" ID="fakepanel" Height="30px">
</asp:Panel>
<div class="Center" style="margin-bottom: 0px; margin-top: 0cm; font-family: MS Pゴシック">
<asp:Panel ID="pnPageIndex" runat="server">
<span>Page
<asp:Label ID="lbPageIndex" runat="server" /><span>/</span><asp:Label ID="lblTotalPage"
runat="server"></asp:Label>
<span>(<asp:Label ID="lbTotal" runat="server"></asp:Label>件)</span></span>
</asp:Panel>
</div>
<table style="width: 100%;position: absolute; bottom: 0px">
<tr style="margin: 0px 0px 0px 0px;">
<td class="BasicValue" style="margin: 0px 0px 0px 0px; width: 100%; padding: 5px 10px 5px 10px">
<asp:Button ID="btnEditNotification" CssClass="ButtonSchedule" runat="server" Text="お知らせの編集"
Height="85%" Style="float: left; text-align: center; margin: 0px 10px 0px 0px; position: relative; left: 260px"
Width="158px" OnClick="btnEditNotification_Click" />
<asp:Button ID="btnUpdateNotification" CssClass="ButtonSchedule" runat="server" Text="このお知らせに追記"
Height="85%" Style="float: right; text-align: center; margin: 0px 5px 0px 0px;"
Width="158px" OnClick="btnUpdateNotification_Click" />
</td>
</tr>
</table>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="grvHeadline" EventName="SelectedIndexChanged" />
<asp:AsyncPostBackTrigger ControlID="gdvNotification" EventName="PageIndexChanging" />
</Triggers>
</asp:UpdatePanel>
</td>
</tr>
</table>
Can somebody tell me what's happening?
(p/s: i'm trying to learning English, if you don't understand, please tell me.)
Related
I have ajax telerik tabs in my code and when I switch the tabs my controls loses whatever I have typed.
I tried "enableViewState" to true. It didn't work either.
What I want is the controls to retain values entered on tab switch
<telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
<telerik:RadTabStrip ID="RadTabStrip1" runat="server" MultiPageID="RadMultiPage1" Width="100%" Align="Justify" >
<Tabs>
<telerik:RadTab PageViewID="RadPageView1" NavigateUrl="CreateNewUser.aspx?TabIndex=0" Text="Adviser Details" HoveredCssClass="hoveredTab" Font-Bold="true" />
<telerik:RadTab PageViewID="RadPageView2" NavigateUrl="CreateNewUser.aspx?TabIndex=1" Text="Fee Split" HoveredCssClass="hoveredTab" Font-Bold="true" />
<telerik:RadTab PageViewID="RadPageView3" NavigateUrl="CreateNewUser.aspx?TabIndex=2" Text="Signature" HoveredCssClass="hoveredTab" Font-Bold="true" />
<telerik:RadTab PageViewID="RadPageView4" NavigateUrl="CreateNewUser.aspx?TabIndex=3" Text="Reference Details" HoveredCssClass="hoveredTab" Font-Bold="true" />
</Tabs>
</telerik:RadTabStrip>
<telerik:RadMultiPage ID="RadMultiPage1" runat="server" Width="100%" RenderSelectedPageOnly="false">
<telerik:RadPageView ID="RadPageView1" runat="server" Height="100%" CssClass="RadPageViewBorder">
<div style="padding: 10px 10px 10px 10px; background-color: white;">
<uc1:AdvisorDetails ID="UCAdvisorDetails" runat="server" />
</div>
</telerik:RadPageView>
<telerik:RadPageView ID="RadPageView2" runat="server" Width="100%" Height="100%" CssClass="RadPageViewBorder">
<div style="padding: 0px 0px 0px 0px; background-color: white;">
<uc1:AdvisorFeeSplit runat="server" ID="UCAdvisorFeeSplit" />
</div>
</telerik:RadPageView>
<telerik:RadPageView ID="RadPageView3" runat="server" Width="100%" Height="100%" CssClass="RadPageViewBorder">
<div style="padding: 0px 0px 0px 0px; background-color: white;">
<uc1:AdvisorSignature ID="UCAdvisorSignature" runat="server" />
</div>
</telerik:RadPageView>
<telerik:RadPageView ID="RadPageView4" runat="server" Width="100%" Height="100%" CssClass="RadPageViewBorder">
<div style="padding: 0px 0px 0px 0px; background-color: white;">
<uc1:AdvisorReferenceDetails runat="server" ID="UCAdvisorReferenceDetails" />
</div>
</telerik:RadPageView>
</telerik:RadMultiPage>
<div class="col100" style="padding-top: 35px; padding-left: 30px; padding-right: 30px;">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="btnAddUser" ValidationGroup="vgUser" runat="server" Width="120px" Text="Save" CssClass="btn-common" OnClick="btnAddUser_Click" />
<asp:Button ID="btnDeleteUser" ValidationGroup="vgUser" runat="server" Width="120px" Text="Delete" CssClass="btn-common" OnClick="btnDeleteUser_Click"/>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="btnAddUser"/>
<asp:PostBackTrigger ControlID="btnDeleteUser"/>
</Triggers>
</asp:UpdatePanel>
</div>
<div class="col100">
<span class="failureNotification">
<asp:Literal ID="litError" runat="server"></asp:Literal>
</span>
<span class="successNotification">
<asp:Literal ID="litSuccess" runat="server"></asp:Literal>
</span>
</div>
Can someone point out the issue pls ?
Your tabs have NavigateUrl property set, which means they render as links, which means they redirect, they do not use ajax.
That's why the values are not persisted.
Hi I am doing a social network service using asp.net/c#, I have little problems with message sending. Message are flowed top to bottom. Like this
But I want to display messages bottom to top Like facebook..
I am displaying messages using repeater control.
repeater control code
<asp:Repeater runat="server" ID="Repeater1">
<ItemTemplate>
<div style="border-top: thin none #BBCEB3; border-bottom: thin none #BBCEB3; padding: 10px; width: 548px; margin-top: 10px; right: 10px; left: 10px; border-left-width: thin; margin-left: 15px; background-color: #e9eaee; border-left-color: #BBCEB3; border-right-color: #BBCEB3;">
<br />
<div style="width: 58px; height: 40px">
<asp:Image ID="Image2" runat="server" Height="59px" ImageAlign="Top" ImageUrl="~/Profile/Image/Default.png" Width="55px" />
</div>
<div style="width: 307px; margin-left: 65px; margin-top: -60px">
<asp:Label ID="Label6" runat="server" Font-Bold="True" Font-Names="Arial" ForeColor="#000066"><%#Eval("SenderID") %> </asp:Label>
</div>
<div id="status" style=" width: 461px; margin-left: 78px; margin-top: 11px;"> <asp:Label ID="Label7" runat="server" Font-Italic="False" ForeColor="Black" Font-Size="Medium"><%#Eval("Messages") %> </asp:Label>
</div>
<div style="margin-left: 350px">
<asp:Label ID="Label11" runat="server" Text="Posted on: " Font-Size="Small"><%#Eval("Time") %> </asp:Label>
</div>
</div>
</ItemTemplate>
Textbox code
<asp:TextBox ID="Message" runat="server" OnTextChanged="TextBox3_TextChanged" style="margin-left: 12px; text-align: left;" TextMode="MultiLine" Width="564px" Height="100px"></asp:TextBox>
The order of Items in the repeater will be the same as in DataSource, so just Order it by Time descending before bind.
In my page, I have a text_change event that is fired and it goes to the database, looks up a value, then sets textbox and hidden field. After those fields are set, I display modal popup to validate the values returned. The issue is once the popup is displayed, it takes about 30 seconds before the close button is active. I have narrowed it down to the text_change event because I have several text_change events on the page which show a modal popup for validation and I get the same behavior for all of them. I do not get the same behavior when I trigger the validation summary on the page from a button_click event I am not sure why there is a delay and how to get past this issue.
<%# Page Title="" Language="C#" MasterPageFile="~/MasterPage/SiteMaster.master" AutoEventWireup="true"
CodeBehind="PoReceiving.aspx.cs" Inherits="ChatWirelessWebOLPApp.PoReceiving" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<table width="100%">
<tr>
<td class="page-heading" colspan="3" style="height: 20px;">
PO Receiving
<hr style="width: 99%; margin: 5px 0 10px 5px; padding: 0; background-color: #000;" />
</td>
</tr>
</table>
<div id="dvBody" style="width: 100%; float: left; margin: -24px 0 0 0; padding: 0;">
<div style="width: 950px; margin: 0 auto 0 auto; font-family: Calibri; font-size: small;">
<div style="width: 100%; float: left; margin: 30px 0 0 0; display: block;" id="Div2">
</div>
<div style="width: 100%; float: left; margin: -25px 0 0 0; display: block;" id="dvRo">
<div id="dv_RmaInfo" style="width: 950px; margin: 10px auto 0 auto; border: 1px solid #ccc;">
<table style="width: 90%;" align="center">
<tr>
<td colspan="2" align="center" style="height: 30px;">
<asp:Label ID="lblMsg" runat="server" CssClass="ErrorMsg" />
</td>
<tr>
<td align="right">
<asp:Label ID="lblpallet" runat="server" Width="150px" Text="Pallet Nbr: " Style="margin-right: 5px;"></asp:Label>
</td>
<td align="left">
<asp:TextBox ID="txtPalletId" runat="server" Width="150px" />
<asp:RequiredFieldValidator ID="rfvPkNbr" runat="server" Font-Bold="true" Font-Size="Medium"
ErrorMessage="Pallet Nbr Required" ForeColor="#FF3300" ControlToValidate="txtPalletId"
Display="Dynamic" ValidationGroup="group1">*</asp:RequiredFieldValidator>
<asp:Button ID="btnSearch" runat="server" Text="Search" Width="100px" Style="width: 100px;
padding: 2px 0; cursor: pointer; margin-left: 5px; background: #0071bd; border: 1px solid #ccc;
color: #fff; font-family: Arial; font-size: 12px;" OnClick="btnSearch_Click" />
</td>
</tr>
</table>
<asp:HiddenField ID="HiddenField1" runat="server" />
<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" PopupControlID="pnlPopup1"
TargetControlID="HiddenField1" OkControlID="btnDlgOK1" BackgroundCssClass="modalPopUp"
DropShadow="true">
</ajaxToolkit:ModalPopupExtender>
<asp:Panel ID="pnlPopup1" runat="server" CssClass="popUp" Width="300px">
<br />
<table align="center">
<tr>
<td align="center">
<asp:ValidationSummary HeaderText="The following errors occurred:" ID="ValidationSummary1"
ValidationGroup="group1" Font-Names="Calibri" Font-Size="Medium" Visible="true"
runat="server" ForeColor="Black" align="left" />
</td>
</tr>
<tr>
<td align="center">
<asp:Label ID="lblPopUpMsg1" runat="server" Font-Names="Calibri" Font-Size="Medium"
Visible="False"></asp:Label>
</td>
</tr>
<tr>
<td align="center">
<br />
<asp:Button ID="btnDlgOK1" CssClass="button" runat="server" Style="width: 100px;
padding: 2px 0; cursor: pointer; margin-left: 5px; height: 23px; background: #0071bd;
border: 1px solid #ccc; color: #fff; font-family: Arial; font-size: 12px;" Text="Close" />
</td>
</tr>
<tr>
<td>
<br />
</td>
</tr>
</table>
</asp:Panel>
</div>
<%--<br />
<br />--%>
<asp:Panel ID="panel1" runat="server" Visible="false">
<br />
<div id="Div3" style="width: 950px; margin: 10px auto 0 auto; border: 1px solid #ccc;">
<table cellpadding="2" cellspacing="0">
<tr>
<td align="right">
<asp:Label ID="Label6" runat="server" Text="Shopping Cart:" />
</td>
<td align="left">
<asp:TextBox ID="txtShoppingCart" runat="server" /><asp:RequiredFieldValidator ID="rfvtxtShoppingCart"
runat="server" Font-Bold="true" Font-Size="Medium" ErrorMessage="Shopping Cart Required"
ForeColor="#FF3300" ControlToValidate="txtShoppingCart" Display="Dynamic" ValidationGroup="group2">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="Label7" runat="server" Text="Enter Ship to Code:" />
</td>
<td align="left">
<asp:TextBox ID="txtShipToCode" runat="server" Width="65px" AutoPostBack="true" OnTextChanged="txtShipToCode_TextChanged" /><asp:RequiredFieldValidator
ID="rfvtxtShipToCode" runat="server" Font-Bold="true" Font-Size="Medium" ErrorMessage="Ship Code Required"
ForeColor="#FF3300" ControlToValidate="txtShipToCode" Display="Dynamic" ValidationGroup="group2">*</asp:RequiredFieldValidator>
</td>
<td align="left" colspan="4">
<asp:TextBox ID="txtMarket" runat="server" Enable="false" Width="250px" />
<asp:HiddenField ID="hdnLocId" runat="server" />
<%--<asp:DropDownList
ID="ddlMarket" runat="server" Visible="false" /><asp:RequiredFieldValidator ID="rfvtxtMarket"
runat="server" Font-Bold="true" Font-Size="Medium" ErrorMessage="Select a Market" InitialValue="none"
ForeColor="#FF3300" ControlToValidate="ddlMarket" Display="Dynamic" ValidationGroup="group2">*</asp:RequiredFieldValidator>--%>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="Label8" runat="server" Text="Customer Part Nbr/Mfg Part Nbr:" />
</td>
<td align="left">
<asp:TextBox ID="txtPartNbr" runat="server" AutoPostBack="true" OnTextChanged="txtPartNbr_TextChanged" /><asp:RequiredFieldValidator
ID="rfvtxtPartNbr" runat="server" Font-Bold="true" Font-Size="Medium" ErrorMessage="Part Nbr Required"
ForeColor="#FF3300" ControlToValidate="txtPartNbr" Display="Dynamic" ValidationGroup="group2">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right" valign="top">
<asp:Label ID="Label9" runat="server" Text="Mfg Part Nbr:" />
</td>
<td align="left" valign="top">
<asp:TextBox ID="txtMfgPartNbr" runat="server" Enabled="false" />
</td>
<td align="right" valign="top">
<asp:Label ID="label11" runat="server" Text="Serialized:" />
</td>
<td align="left" valign="top">
<asp:TextBox ID="txtSerialized" runat="server" Enabled="false" Width="46px" />
</td>
<td align="right" valign="top">
<asp:Label ID="label10" runat="server" Text="Part Description:" />
</td>
<td align="left" valign="top">
<asp:TextBox ID="txtDescription" runat="server" Enabled="false" Height="51px" Width="257px"
TextMode="MultiLine" />
</td>
</tr>
<tr id="rowSerialized" runat="server" visible="false">
<td align="right">
<asp:Label ID="label12" runat="server" Text="TMO Asset Nbr:" />
</td>
<td align="left">
<asp:TextBox ID="txtAssetNbr" runat="server" /><asp:RequiredFieldValidator ID="rfvTxtAssetNbr"
runat="server" Font-Bold="true" Font-Size="Medium" ErrorMessage="T-Mobile Asset Tag Required"
ForeColor="#FF3300" ControlToValidate="txtAssetNbr" Display="Dynamic" ValidationGroup="group2">*</asp:RequiredFieldValidator>
</td>
<td align="right">
<asp:Label ID="label13" runat="server" Text="Serial Nbr:" />
</td>
<td align="left">
<asp:TextBox ID="txtSerialNbr" runat="server" Width="102px" /><asp:RequiredFieldValidator
ID="rfvTxtSerialNbr" runat="server" Font-Bold="true" Font-Size="Medium" ErrorMessage="Serial Nbr Required"
ForeColor="#FF3300" ControlToValidate="txtSerialNbr" Display="Dynamic" ValidationGroup="group2">*</asp:RequiredFieldValidator>
</td>
<td align="right">
<asp:Label ID="label17" runat="server" Text="Putaway Bin:" />
</td>
<td align="left">
<asp:TextBox ID="txtBin1" runat="server" />
</td>
</tr>
<tr id="rowNonSerialized" runat="server" visible="false">
<td align="right">
<asp:Label ID="label14" runat="server" Text="Quantity:" />
</td>
<td align="left">
<asp:TextBox ID="txtQty" runat="server" ontextchanged="txtQty_TextChanged" AutoPostBack="true" /><asp:RequiredFieldValidator ID="rfvTxtQty"
runat="server" Font-Bold="true" Font-Size="Medium" ErrorMessage="Quantity Required"
ForeColor="#FF3300" ControlToValidate="txtQty" Display="Dynamic" ValidationGroup="group2">*</asp:RequiredFieldValidator>
</td>
<td align="right">
<asp:Label ID="label16" runat="server" Text="Putaway Bin:" />
</td>
<td align="left" colspan="2">
<asp:TextBox ID="txtBin2" runat="server" Width="97px" />
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="label15" runat="server" Text="Nbr of Labels:" />
</td>
<td align="left">
<asp:TextBox ID="txtNbrOfLabels" runat="server" /><asp:RequiredFieldValidator ID="rfvTxtNbrOfLabels"
runat="server" Font-Bold="true" Font-Size="Medium" ErrorMessage="Number of labels to print Required"
ForeColor="#FF3300" ControlToValidate="txtNbrOfLabels" Display="Dynamic" ValidationGroup="group2">*</asp:RequiredFieldValidator>
</td>
<td align="right">
<asp:Label ID="label18" runat="server" Text="Clear Shopping Cart:" />
</td>
<td>
<asp:DropDownList ID="ddlCloseShoppingCart" runat="server">
<asp:ListItem Selected="True" Text="NO" Value="no" />
<asp:ListItem Text="YES" Value="yes" />
</asp:DropDownList>
</td>
<td align="right">
<asp:Label ID="label19" runat="server" Text="Clear Pallet:" />
</td>
<td>
<asp:DropDownList ID="ddlClosePallet" runat="server">
<asp:ListItem Selected="True" Text="NO" Value="no" />
<asp:ListItem Text="YES" Value="yes" />
</asp:DropDownList>
</td>
</tr>
<tr>
<td colspan="6" align="center">
<br />
<asp:Button ID="btnSave" runat="server" Text="Save" Style="width: 100px;
padding: 2px 0; cursor: pointer; margin-left: 5px; height: 23px; background: #0071bd;
border: 1px solid #ccc; color: #fff; font-family: Arial; font-size: 12px;" OnClick="btnSave_Click" />
<asp:Button
ID="btnReset" Style="width: 100px; padding: 2px 0; cursor: pointer;
margin-left: 5px; height: 23px; background: #0071bd; border: 1px solid #ccc;
color: #fff; font-family: Arial; font-size: 12px;" runat="server" Text="Reset"
OnClick="btnReset_Click" />
</td>
</tr>
</table>
<asp:HiddenField ID="HiddenField2" runat="server" />
<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender2" runat="server" PopupControlID="pnlPopup2"
TargetControlID="HiddenField2" OkControlID="btnDlgOK2" BackgroundCssClass="modalPopUp"
DropShadow="true">
</ajaxToolkit:ModalPopupExtender>
<asp:Panel ID="pnlPopup2" runat="server" CssClass="popUp" Width="300px">
<br />
<table align="center">
<tr>
<td align="center">
<asp:ValidationSummary HeaderText="The following errors occurred:" ID="ValidationSummary2"
ValidationGroup="group2" Font-Names="Calibri" Font-Size="Medium" Visible="true"
runat="server" ForeColor="Black" align="left" />
</td>
</tr>
<tr>
<td align="center">
<asp:Label ID="lblPopUpMsg2" runat="server" Font-Names="Calibri" Font-Size="Medium"
Visible="False"></asp:Label>
</td>
</tr>
<tr>
<td align="center">
<br />
<asp:Button ID="btnDlgOK2" CssClass="button" runat="server" Style="width: 100px;
padding: 2px 0; cursor: pointer; margin-left: 5px; height: 23px; background: #0071bd;
border: 1px solid #ccc; color: #fff; font-family: Arial; font-size: 12px;" Text="Close" />
</td>
</tr>
<tr>
<td>
<br />
</td>
</tr>
</table>
</asp:Panel>
<asp:HiddenField ID="HiddenField3" runat="server" />
<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender3" runat="server" PopupControlID="pnlPopup3" TargetControlID="HiddenField3"
BackgroundCssClass="modalPopUp" DropShadow="true">
</ajaxToolkit:ModalPopupExtender>
<asp:Panel ID="pnlPopup3" runat="server" CssClass="popUp" Width="300px">
<br />
<table align="center">
<tr><td align="center">
<asp:ValidationSummary HeaderText="Form Validation:" ID="ValidationSummary3" ValidationGroup = "group2"
Font-Names="Calibri" Font-Size="Medium" Visible="true" runat="server" ForeColor="Black" align="left"/>
</td></tr>
<tr><td>
<asp:Label ID="lblPopUpMsg3" runat="server" Font-Names="Calibri" Font-Size="Medium"
Visible="False"></asp:Label>
</td> </tr>
<tr>
<td align="center">
<br />
<asp:Button ID="btnDlgOK3" runat="server" CssClass="button" OnClick="btnDlgOK3_Click"
Style="width: 100px; padding: 2px 0; cursor: pointer; margin-left: 5px; height: 23px;
background: #0071bd; border: 1px solid #ccc; color: #fff; font-family: Arial;
font-size: 12px;" Text="Continue" />
<asp:Button ID="btnDlgCancel3" runat="server" CssClass="button" OnClick="btnDlgCancel3_Click"
Style="width: 100px; padding: 2px 0; cursor: pointer; margin-left: 5px; height: 23px;
background: #0071bd; border: 1px solid #ccc; color: #fff; font-family: Arial;
font-size: 12px;" Text="Cancel" />
</td>
</tr>
<tr>
<td>
<br />
</td>
</tr>
</table>
</asp:Panel>
</div>
</asp:Panel>
</div>
</div>
</div>
<input type="hidden" id="printConfirm" runat="server" />
<input type="hidden" id="printString" runat="server" />
<input type="hidden" id="nbrLabels" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress ID="BusyIndicator" runat="server" DynamicLayout="true" AssociatedUpdatePanelID="UpdatePanel1">
<ProgressTemplate>
<div class="progress">
<asp:Image ID="Image2" runat="server" ImageUrl="~/images/ajax-loader.gif" />
</div>
</ProgressTemplate>
</asp:UpdateProgress>
</asp:Content>
protected void txtShipToCode_TextChanged(object sender, EventArgs e)
{
if (txtShipToCode.Text != "" && !string.IsNullOrEmpty(txtShipToCode.Text))
{
PoReceivingDBHandler po = new PoReceivingDBHandler();
DataTable location = new DataTable();
string msg = string.Empty;
if (!po.GetShipToLocation(txtShipToCode.Text.Trim().ToUpper(), ref location, ref msg))
{
ErrorLogging log = new ErrorLogging();
log.LogError("PoReceiving.aspx.cs-txtShipToCode_TextChanged", "DB ERror", string.Empty, string.Empty, msg, HttpContext.Current.Session["LoginID"].ToString());
ValidationSummary2.Visible = false;
ModalPopupExtender2.Show();
lblPopUpMsg2.Text = msg;
lblPopUpMsg2.Visible = true;
return;
}
else
{
if (location.Rows.Count > 0)
{
txtMarket.Text = location.Rows[0]["LOC_DESC"].ToString();
hdnLocId.Value = location.Rows[0]["LOC_ID"].ToString();
//ValidationSummary2.Visible = false;
ModalPopupExtender2.Show();
lblPopUpMsg2.Text = "Please verify Market matches code entered.";
lblPopUpMsg2.Visible = true;
//return;
}
else
{
txtMarket.Text = string.Empty;
//ValidationSummary2.Visible = false;
ModalPopupExtender2.Show();
lblPopUpMsg2.Text = "No market was found for the code entered.\n\rPlease check and re-enter the code.";
lblPopUpMsg2.Visible = true;
}
}
}
}
I have a Submit button on the page, which upon being clicked, shows a modal popup window. This modal popup window contains a checkbox that must be checked before the OK button of the modal can be clicked:
<script language="javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script language="javascript" type="text/javascript">
function cvcbCertify_ClientValidate(sender, e) {
var elem = document.getElementById('<%= cbCertify.ClientID %>');
if (elem.checked)
e.IsValid = true;
else {
$('.pnlConfirm').show(); //not working?
e.IsValid = false;
}
}
<ajaxToolkit:ConfirmButtonExtender ID="cbeResponseReferralSignOff" runat="server"
TargetControlID="ResponseLocalSignOff" DisplayModalPopupID="popConfirm">
</ajaxToolkit:ConfirmButtonExtender>
<ajaxToolkit:ModalPopupExtender runat="server" ID="popConfirm" TargetControlID="ResponseLocalSignOff"
BackgroundCssClass="modalBackground" DropShadow="true" OkControlID="btnConfirmCertify"
CancelControlID="btnCancel" PopupControlID="pnlConfirm">
</ajaxToolkit:ModalPopupExtender>
<asp:Panel runat="server" ID="pnlConfirm" Style="display: none; background-color: White;
border: solid 1px Gray; width: 90%; height: 100%; padding: 10px" CssClass="pnlConfirm">
<asp:Panel runat="server" ID="pnlConfirm" Style="display: none; background-color: White;
border: solid 1px Gray; width: 90%; height: 100%; padding: 10px" CssClass="pnlConfirm">
popup text here
<asp:CheckBox runat="server" ID="cbCertify" Text="I Certify" CssClass="cbCertify">
</asp:CheckBox>
<br />
<asp:CustomValidator runat="server" ID="cvcbCertify" ClientValidationFunction="cvcbCertify_ClientValidate">Required.</asp:CustomValidator>
<br />
<div style="text-align: center">
<asp:Button runat="server" ID="btnConfirmCertify" Text="OK" />
<asp:Button runat="server" ID="btnCancel" Text="Cancel" />
</div>
</asp:Panel>
The problem is the modal window closes when validation fails. How do I prevent this window from closing or repoppen this window?
The only way to do this is by using an UpdatePanel. Additionally this will allow you to use AsyncPostBackTrigger with a Conditional UpdateMode with control events as well.
For example
<asp:Panel runat="server" ID="pnlConfirm" Style="display: none; background-color: White;
border: solid 1px Gray; width: 90%; height: 100%; padding: 10px" CssClass="pnlConfirm">
<asp:UpdatePanel ID="upItem" runat="server">
<ContentTemplate>
popup text here
<asp:CheckBox runat="server" ID="cbCertify" Text="I Certify" CssClass="cbCertify">
</asp:CheckBox>
<br />
<asp:CustomValidator runat="server" ID="cvcbCertify" ClientValidationFunction="cvcbCertify_ClientValidate">Required.</asp:CustomValidator>
<br />
<div style="text-align: center">
<asp:Button runat="server" ID="btnConfirmCertify" Text="OK" />
<asp:Button runat="server" ID="btnCancel" Text="Cancel" />
</div>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
Solution was to get rid of the ConfirmButtonExtender and make my own validation:
function Validate_Click() {
//using asp.net checkbox so have to go this route to get bool
var checked = $('#<%= cbCertify.ClientID %>').is(':checked');
if (checked) {
$('.lblConfirmCertifyError').hide();
return true;
}
else {
$('.lblConfirmCertifyError').show();
return false;
}
}
<asp:Panel runat="server" ID="pnlConfirm" Style="display: none; background-color: White;
border: solid 1px Gray; width: 90%; height: 100%; padding: 10px">
popup text here
<asp:CheckBox runat="server" ID="cbCertify" Text="I Certify" CssClass="cbCertify">
</asp:CheckBox>
<br />
<asp:Label runat="server" ID="lblConfirmCertifyError" Text="Required." ForeColor="Red"
Style="display: none" CssClass="lblConfirmCertifyError"></asp:Label>
<br />
<div style="text-align: center">
<asp:Button runat="server" ID="btnConfirmCertify" Text="OK" CssClass="btnConfirmCertify" OnClientClick="return Validate_Click()" />
<asp:Button runat="server" ID="btnCancel" Text="Cancel" />
<asp:Button runat="server" ID="btnDummy" Text="" Style="display: none" />
</div>
</asp:Panel>
Just for curiosity can i give a control that is outside a repeater a binneded value
for example :
<asp:Repeater ID="topicRepeater" runat="server">
<ItemTemplate>
<table border="0" id="bodyTable" runat="server" style="width: 100%; height: 100%;">
<tr>
<td align="left" valign="top" style="padding-top: 6px; padding-right: 30px; padding-left: 5px; width: 50px;">
<img src='App_Themes/WebPortalTheme/images/ProfilePicSmall/<%# Eval("ProPic") %>'
style="width: 50px; height: 50px;" />
<div runat="server" id="username" style="padding-left: 8px; color: #002D79;">
<%# Eval("UserName") %></div>
</td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
<telerik:RadTextBox ID="EditedReplyTxt" Text='<%# Eval("msg_text")%>' runat="server" Width="300px" TextMode="MultiLine" Height="100px"></telerik:RadTextBox>
Yes you can, read this example
http://msdn.microsoft.com/fr-fr/library/4hx47hfe(v=vs.80).aspx