asp.net - text boxes lose values entered on tab switch - c#

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.

Related

Changing message displays to bottom to top

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.

why controls in updatepanel disappeared?

I have two UpdatePanel(tvUpdatePanel and tvResultUpdatePanel) on one page, as you can see in the image, the first UpdatePanel contains a text box and a button, the second updatepanel contains three GridViews below(For designing purpose, i have to put these two parts seperately). I've set both UpdatePanel's UpdateMode to "Always". I encountered a strange thing: when clicking "next page" of the gridviews or the "search" button, the three Gridviews will disappear from the page. I have to click the "Tailored View" tab then the GridViews show again. The next page or search function are working well. Why is this happening? How to fix this? Thanks!
<asp:UpdatePanel ID="tvUpdatePanel" runat="server" UpdateMode="Always">
<ContentTemplate>
<div id="TailoredViewTab" style="display: normal">
<%--<uc4:TailoredView runat="server" id="TailoredView" />--%>
<div class="div_options" style="margin-top: 10px; font-style: italic;">
Complete code search criteria below and click <b>SEARCH</b> button.
</div>
<asp:DropDownList ID="geographicalAreasDropDownList" runat="server" Width="100px" Height="20px"
Style="display: none; margin-left: 0px; margin-top: 5px"
DataSourceID="geographicalAreaSqlDataSource"
DataTextField="Description"
DataValueField="ID" />
<ajaxToolkit:HoverMenuExtender ID="hme4ga" runat="server"
TargetControlID="geographicalAreasDropDownList"
PopupControlID="gaHoverPanel"
PopupPosition="Bottom"
HoverDelay="0"
OffsetX="0"
OffsetY="10"
PopDelay="0">
</ajaxToolkit:HoverMenuExtender>
<asp:DropDownList ID="newsAreasDropDownList" runat="server" Height="20px"
DataSourceID="newsAreasSqlDataSource"
DataTextField="Description"
DataValueField="ID"
Style="display: none; margin-left: 60px; margin-top: -15px" Width="200px" />
<ajaxToolkit:HoverMenuExtender ID="hme4na" runat="server"
TargetControlID="newsAreasDropDownList"
PopupControlID="naHoverPanel"
PopupPosition="Bottom"
OffsetX="0"
OffsetY="10"
PopDelay="0">
</ajaxToolkit:HoverMenuExtender>
<asp:TextBox ID="tvSearchTbx" runat="server" Text="" Height="20px" CausesValidation="true"
onkeypress="return UserPressKeyOnTVTB(event);"
Style="margin-left: 0px; margin-top: -20px" Width="650px" />
<ajaxToolkit:HoverMenuExtender ID="hme4st" runat="server"
TargetControlID="tvSearchTbx"
PopupControlID="stHoverPanel"
PopupPosition="Bottom"
OffsetX="20"
OffsetY="10"
PopDelay="0">
</ajaxToolkit:HoverMenuExtender>
<span class="btn_wrap span_margin_left10">
<asp:Button ID="tvSearchBtn" runat="server" CssClass="input_btn" Height="20px" Style="margin-top: -20px; margin-left: 100px;" Text="Search" OnClick="tvSearchBtn_Click" />
</span>
<%--<asp:RequiredFieldValidator ID="tbxValidator" runat="server" Style="position: relative; margin-left: 250px; margin-top: 25px; color: #FC890D; font-size: large" ErrorMessage="* Incomplete search request - Please complete all search criteria." ControlToValidate="searchTextBox"></asp:RequiredFieldValidator>--%>
<div runat="server" id="errorMessageDiv" style="margin-top: 50px; display: none; height: 40px; width: 100%; text-align: center; font-size: x-large; color: #FC890D">
</div>
<asp:SqlDataSource ID="geographicalAreaSqlDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:RDSConnectionString %>"
SelectCommand="STP_GetGeographicalAreas"
SelectCommandType="StoredProcedure"></asp:SqlDataSource>
<asp:SqlDataSource ID="newsAreasSqlDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:RDSConnectionString %>"
SelectCommand="STP_GetNewsAreas"
SelectCommandType="StoredProcedure"></asp:SqlDataSource>
<div style="text-align: center">
<asp:UpdateProgress ID="progress" runat="server" DisplayAfter="100" DynamicLayout="true">
<ProgressTemplate>
<img src="img/LoadingTailoredView.gif" alt="Loading data, please wait..." />
</ProgressTemplate>
</asp:UpdateProgress>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="tvResultUpdatePanel" runat="server" UpdateMode="Always">
<ContentTemplate>
<div id="TailoredViewResultTab" style="display: none">
<div id="TopicCodesGridViewDiv" class="RoundCornerDiv" style="background-color: transparent; position: relative; display: normal; width: 30%; height: 250px; top: 30px; margin-left: 0px; margin-right: 33%">
<div id="TopicCodesLabelDiv" style="height: 20px; margin-top: -53px; margin-left: 20%; margin-right: 20%; display: normal; text-align: center; font-size: large; color: #ff6a00">
<asp:Label ID="TopicCodesLabel" runat="server" Class="label">Topic Codes</asp:Label>
</div>
<asp:GridView ID="TopicCodesGridView" runat="server" CellPadding="3" DataSourceID="TopicCodesResult"
OnSelectedIndexChanged="TopicCodesGridView_SelectedIndexChanged"
OnPageIndexChanging="TopicCodesGridView_PageIndexChanging"
Style="margin-top: 3px; table-layout: fixed; max-width: 100%;"
OnRowDataBound="TopicCodesGridView_RowDataBound"
AllowSorting="True"
AutoGenerateColumns="false"
AllowPaging="True" BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" CellSpacing="2">
<Columns>
<asp:TemplateField HeaderText="Code">
<ItemTemplate>
<div>
<%#Eval("Code") %>
</div>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Description" ItemStyle-CssClass="gridViewLeftAlign">
<ItemTemplate>
<div class="tailoredViewGridViewRight" style="width: 100%; height: 100%">
<%#Eval("Description") %>
</div>
</ItemTemplate>
</asp:TemplateField>
<%-- <asp:CommandField ShowSelectButton="true" ButtonType="Button" Visible="true" />--%>
</Columns>
<FooterStyle BackColor="#FC890D" ForeColor="#8C4510" />
<HeaderStyle BackColor="#FC890D" Font-Bold="True" ForeColor="White" Width="50px" />
<PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" BackColor="#FC890D" />
<PagerSettings Mode="NextPreviousFirstLast" />
<RowStyle Width="150px" BackColor="#FFF7E7" ForeColor="#8C4510" />
<SelectedRowStyle BackColor="#FC890D" Font-Bold="True" ForeColor="Green" />
<SortedAscendingCellStyle BackColor="#FFF1D4" />
<SortedAscendingHeaderStyle BackColor="#B95C30" />
<SortedDescendingCellStyle BackColor="#F1E5CE" />
<SortedDescendingHeaderStyle BackColor="#93451F" />
</asp:GridView>
</div>
<div id="treeViewDiv" class="RoundCornerDiv" style="margin-top: auto; position: relative; display: normal; width: 30%; height: 250px; top: -346px; margin-left: 33%; margin-right: 33%">
<div id="treeViewLabelDiv" style="margin-top: -53px; margin-left: 20%; margin-right: 20%; display: normal; text-align: center; font-size: large; color: #ff6a00">
<asp:Label ID="treeViewLabel" runat="server" Class="label">Topic Tree View</asp:Label>
</div>
<div id="tvTreeViewDiv" class="TailoredViewScroll" style="margin-top: 3px; text-align: left; overflow: scroll; height: 290px;">
<ul id="tvTreeView" class="filetree">
<li>
<span title="title" class="folder">Folder0</span>
<ul>
<li title="This is child 0">
<span class="file" style="color: red">Child 0</span>
</li>
<li class="file" title="This is child 1" style="visibility: visible">
<span class="file">Child 1</span>
</li>
<li title="This is child 2" style="visibility: visible">
<span class="file">Child 2</span>
</li>
<li title="This is child 1">
<span class="file">Child 1</span>
</li>
<li title="This is child 4" style="visibility: visible">
<span class="file">Child 4</span>
</li>
<li title="This is child 5" style="visibility: visible">
<span class="file">Child 5</span>
</li>
<li title="This is child 2">
<span class="file">Child 2</span>
</li>
<li class="file" title="This is child 1" style="visibility: visible">
<span class="file">Child 1</span>
</li>
<li title="This is child 2" style="visibility: visible">
<span class="file">Child 2</span>
</li>
<li title="This is child 3">
<span class="file">Child 3</span>
</li>
<li title="This is child 4" style="visibility: visible">
<span class="file">Child 4</span>
</li>
<li title="This is child 5" style="visibility: visible">
<span class="file">Child 5</span>
</li>
<li title="This is folder 2">
<span class="folder">Folder 1</span>
<ul>
<li title="This is folder 2's child 1">
<span class="file">child child 00</span>
</li>
<li title="This is child 4" style="visibility: visible">
<span class="file">Child 4</span>
</li>
<li title="This is child 1">
<span class="file">child child 01</span>
</li>
<li title="This is child 4" style="visibility: visible">
<span class="file">Child 4</span>
</li>
<li>
<span class="folder">Folder 2</span>
<ul>
<li>
<span class="file">file 0000</span>
</li>
<li>
<span class="file">file 0000</span>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div id="RecurringReportsGridViewDiv" class="RoundCornerDiv" style="position: relative; display: normal; width: 30%; height: 250px; top: -722px; margin-left: 66%">
<div id="RecurringReportsLabelDiv" style="margin-top: -53px; margin-left: 20%; margin-right: 20%; display: normal; text-align: center; font-size: large; color: #ff6a00">
<asp:Label ID="RecurringReportsLabel" runat="server" Text="Label" Class="label">Recurring Reports</asp:Label>
</div>
<asp:GridView ID="RecurringReportsGridView" runat="server" CellPadding="3" DataSourceID="RecurringReportsResult"
Style="margin-top: 3px; table-layout: fixed; max-width: 100%;"
OnRowDataBound="RecurringReportsGridView_RowDataBound"
AllowSorting="True" AutoGenerateColumns="False" AllowPaging="True" BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" CellSpacing="2">
<Columns>
<asp:TemplateField HeaderText="Code">
<ItemTemplate>
<div>
<%#Eval("Code") %>
</div>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Description" ItemStyle-CssClass="gridViewLeftAlign">
<ItemTemplate>
<div class="tailoredViewGridViewRight" style="width: 100%; height: 100%">
<%#Eval("Description") %>
</div>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#FC890D" ForeColor="#8C4510" />
<HeaderStyle BackColor="#FC890D" Font-Bold="True" ForeColor="White" HorizontalAlign="Left" Width="50px" />
<PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" BackColor="#FC890D" />
<PagerSettings Mode="NextPreviousFirstLast" />
<RowStyle Width="150px" BackColor="#FFF7E7" ForeColor="#8C4510" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#FFF1D4" />
<SortedAscendingHeaderStyle BackColor="#B95C30" />
<SortedDescendingCellStyle BackColor="#F1E5CE" />
<SortedDescendingHeaderStyle BackColor="#93451F" />
</asp:GridView>
</div>
<asp:ObjectDataSource ID="CompanryRicsResult" runat="server"
TypeName="TR.News.RDWS.SearchTool.DataManager.DataManagerRepository"
OldValuesParameterFormatString="original_{0}"
SelectMethod="GetCompanyRics4TailoredView"></asp:ObjectDataSource>
<asp:ObjectDataSource ID="TopicCodesResult" runat="server"
SelectMethod="GetTopicCodes4TailoredView"
OldValuesParameterFormatString="original_{0}"
TypeName="TR.News.RDWS.SearchTool.DataManager.DataManagerRepository"></asp:ObjectDataSource>
<asp:ObjectDataSource ID="RecurringReportsResult" runat="server"
SelectMethod="GetRecurringReports4TailoredView"
OldValuesParameterFormatString="original_{0}"
TypeName="TR.News.RDWS.SearchTool.DataManager.DataManagerRepository"></asp:ObjectDataSource>
<asp:Panel runat="server" ID="gaHoverPanel" ForeColor="White" BackColor="#FC890D">
Select primary geographical area of interest
</asp:Panel>
<asp:Panel runat="server" ForeColor="White" BackColor="#FC890D" ID="naHoverPanel">
Select primary news area of interest
</asp:Panel>
<asp:Panel runat="server" ID="stHoverPanel" CssClass="hoverMenu4TailoredView" ForeColor="White" BackColor="#FC890D">
Enter keywords in English that relate to your news area of interest
</asp:Panel>
<div id="CompanyRicsGridViewDiv" class="RoundCornerDiv" style="display: none; width: 30%; height: 550px; top: 30px; margin-left: 0px">
<div id="CompanyRicsLabelDiv" style="margin-left: 20%; margin-right: 20%; text-align: center; display: normal; font-size: large; color: #ff6a00">
<asp:Label ID="CompanyRicsLabel" runat="server" Text="Label" Class="label">Company RICs</asp:Label>
</div>
<asp:GridView ID="CompanyRicsGridView" runat="server" OnDataBound="CompanyRicsGridView_DataBound" CellPadding="3" DataSourceID="CompanryRicsResult"
Style="table-layout: fixed; max-width: 100%;"
OnRowDataBound="CompanyRicsGridView_RowDataBound"
AllowSorting="True" AutoGenerateColumns="False" AllowPaging="True" BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" CellSpacing="2">
<Columns>
<asp:HyperLinkField HeaderStyle-Width="30%" ItemStyle-CssClass="tailoredViewGridViewLeft" DataTextField="RIC" HeaderText="RIC" SortExpression="RIC" DataNavigateUrlFormatString="#CompanyTab">
<HeaderStyle Width="30%" />
<ItemStyle CssClass="tailoredViewGridViewLeft" />
</asp:HyperLinkField>
<asp:TemplateField HeaderText="Name" ItemStyle-CssClass="gridViewLeftAlign">
<ItemTemplate>
<div class="tailoredViewGridViewRight" style="width: 100%; height: 100%">
<%#Eval("Name") %>
</div>
</ItemTemplate>
<ControlStyle Width="250px" />
<ItemStyle CssClass="gridViewLeftAlign" />
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
<HeaderStyle BackColor="#FC890D" Font-Bold="True" ForeColor="White" Width="50px" />
<PagerSettings Mode="Numeric" />
<%-- <PagerTemplate>
<asp:Repeater ID="repFooter" OnItemCommand="repFooter_ItemCommand" runat="server">
<HeaderTemplate>
<div class="pager"></div>
</HeaderTemplate>
<ItemTemplate>
<div class="gridViewPager" >
<asp:LinkButton ID="linkPage" BackColor="Green" ForeColor="Red" Text='<%# Container.DataItem %>' CommandName="ChangePage"
CommandArgument="<%# Container.DataItem %>" runat="server" />
</div>
</ItemTemplate>
<FooterTemplate>
<div class="clear"></div>
</FooterTemplate>
</asp:Repeater>
</PagerTemplate>--%>
<PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" BackColor="#FC890D" />
<RowStyle Width="150px" BackColor="#FFF7E7" ForeColor="#8C4510" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#FFF1D4" />
<SortedAscendingHeaderStyle BackColor="#B95C30" />
<SortedDescendingCellStyle BackColor="#F1E5CE" />
<SortedDescendingHeaderStyle BackColor="#93451F" />
</asp:GridView>`enter code here`
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
I solved the problem by move the tvResultUpdatePanel inside the outter "display:none" Div.

Page load first time:Page index in gridView not working

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.)

Prevent Modal Dialog from closing on submit when client side validation fails

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>

how to fire javascript on a button inside item template

when i click on the button which is inside the item template of gridview then onclientclick event should fire and then call the javascript function but my problem is that there no onclientclick event is fire in item template button.
<%# Page Language="C#" AutoEventWireup="true" EnableEventValidation="false" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!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>
<style type="text/css">
.dvBroker
{
display: none;
position: absolute;
left: 0;
top: 0;
height: 100%;
width: 100%;
background-image: url(image/broker_bg.png);
background-repeat: repeat;
}
.collection_heading2
{
font-family: verdana;
font-size: 12px;
font-weight: bold;
color: #000000;
background-image: url(image/gray_bg.gif);
background-repeat: repeat-x;
height: 20px;
width: 386px;
margin-left: 30%;
margin-top: 50px;
padding: 7px 7px 0px 7px;
border: 3px solid #000000;
border-bottom: none;
text-align: center;
}
.broker_window
{
border: 3px solid #000000;
height: 250px;
overflow: auto;
width: 400px;
background-color:White;
margin-left: 30%;
border-top: none;
padding-top: 10px;
text-align: left;
}
</style>
</head>
<body>
<script type="text/javascript" language="javascript">
function Show()
{
document.getElementById("dvStage").style.display='block';
return false;
}
function Close()
{
document.getElementById("dvStage").style.display='none';
return false;
}
</script>
<form id="form1" runat="server">
<asp:ScriptManager ID="sc1" runat="server" EnablePartialRendering="true">
</asp:ScriptManager>
<div>
<asp:Label ID="lblmsg" runat="server" ForeColor="#FF3300"></asp:Label>
<asp:LinkButton ID="lbnaddnewcharge" runat="server" OnClientClick="return Show();"
Text="Show"></asp:LinkButton>
</div>
<div>
ROLL NO:
<asp:TextBox ID="txtrollno" runat="server"></asp:TextBox>
<div>
STUDENT NAME:
<asp:TextBox ID="txtname" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="ADD" BorderStyle="Ridge" OnClick="btnadd_Click" /></div>
<asp:GridView ID="gvstudent" runat="server" AutoGenerateColumns="False" Width="857px"
OnRowDataBound="gvstudent_RowDataBound" OnSelectedIndexChanged="gvstudent_SelectedIndexChanged1">
<Columns>
<asp:BoundField HeaderText="ROLL NO" DataField="roll_no" />
<asp:BoundField HeaderText="NAME" DataField="name" />
<asp:BoundField HeaderText="TOTAL" DataField="total" />
<asp:BoundField HeaderText="STATUS" DataField="status" />
<asp:TemplateField>
<ItemTemplate>
<asp:Button CommandName="Click" ID="btnclick" OnCommand="btnclick_Click" CommandArgument='<%#Eval("roll_no") %>'
OnClientClick="return Show('aspnetForm','[gvstudent]');" runat="server" Text="Click" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
<div id="dvstage" class="dvBroker">
<div class="collection_heading2">
<div style="float: left">
SUBJECT
</div>
<div style="float: right">
<asp:ImageButton ID="btnclose" runat="server" ImageUrl="~/image/delete.png" OnClientClick="return Close();" />
</div>
</div>
<div class="broker_window">
<asp:UpdatePanel ID="up1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:PopupControlExtender ID="PopupControlExtender1" runat="server" TargetControlID="gvchild"
PopupControlID="btnclick" Position="Center">
</asp:PopupControlExtender>
<asp:GridView ID="gvchild" OnRowDataBound="gvChild_RowDataBound" runat="server" AutoGenerateColumns="false"
EmptyDataText="NO Row in grid view">
<Columns>
<asp:BoundField HeaderText="Subject" DataField="subject_name" />
<asp:TemplateField>
<ItemTemplate>
<asp:TextBox ID="txtsubject" runat="server" Text='<%#Bind("marks") %>'></asp:TextBox></ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:Button ID="btnaddchild" runat="server" Text="ADD" OnClick="btnaddchild_Click" />
<asp:Button ID="btncancle" runat="server" Text="CANCLE" OnClick="btncancle_Click1" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
</form>
</body>
</html>
Use a client-side framework like jQuery. Don't put all the onclick client-side events inline. It bloats your markup and it's harder to maintain. Bind the events instead, e.g. http://api.jquery.com/bind and/or http://api.jquery.com/live.
Since its ASP.NET WebForms, your HTML elements id attributes are rendered as the ClientID property of the server controls, so if that causes problems for you getting a reference to the elements to bind events to via id using a jQuery selector, use jQuery's selectors, http://api.jquery.com/category/selectors .
e.g.
$("input[id$='btnClose'").live("click", function(event) {
$("#dvStage").hide();
event.stopPropagation();
});
$("a[id$='lbnaddnewcharge']").live("click", function(event) {
$("#dvStage").show();
event.stopPropagation();
});

Categories

Resources