I've got a ASP.NET 3.5 sp1 site, and on one page I have two UpdatePanels. The first has a CustomValidator, and the second does not. I want the validation to run ONLY when the button is pressed. Currenlty, when the Gridview in the second updatepanel is edited, it also causes the validation. I've read a lot about how the validation controls in 2.0 used to be messed up, but I'm pretty sure that's not germaine to my problem here (or is it?)
Here's the relevant section of the page...
<asp:UpdatePanel ID="userInput" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
<Triggers>
<asp:PostBackTrigger ControlID="btnSubmit" />
</Triggers>
<ContentTemplate>
<asp:TextBox ID="txtMCCredits" runat="server" Width="28px"></asp:TextBox>
<asp:CustomValidator ID="UserValidator" runat="server" ErrorMessage="*" OnServerValidate="UserValidator_ServerValidate" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" />
<asp:UpdatePanel ID="upData" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="gvMainproCredits" />
</Triggers>
<ContentTemplate>
<asp:GridView ID="gvMainproCredits" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" CellPadding="4" DataSourceID="SqlDataSource1" ForeColor="#333333"
GridLines="None" DataKeyNames="RecordID">
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<Columns>
<!--SNIP-->
<asp:BoundField DataField="RecordID" HeaderText="RecordID" InsertVisible="False"
ReadOnly="True" SortExpression="RecordID" Visible="false" />
<asp:BoundField DataField="DateAdded" HeaderText="DateAdded" SortExpression="DateAdded" />
<asp:CommandField ShowHeader="true" HeaderText="Edit" ShowEditButton="true" />
</Columns>
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#999999" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
You might want to partition the validations using ValidationGroup.
In that way, you can choose to have the button validating only certain controls within the same group.
Only part of the solution, but here is a link how to manually call client-side validation in javascript.
the simpler is:
Page_ClientValidate('Group1');
Related
I'm developing a website for office purpose, there i've to use 'Calendar' tool to pick the date. The calendar will work on a button click, but the problem is whenever the button is clicked to view the calendar the whole page is getting refreshed and the page is going into initial stage, so i tried using updatepanel in the website to restrict this and to refresh only required part of the page. But even though i'm using the correct syntax and everything...still the page is getting refreshed every time.
I'm guessing here that i missed to add any required libraries...So please help me here, if i have to do any pre-configuration to do to use these ajax controllers.
I tried creating one sample website only to check this AJAX functionality by selecting 'WEB API' while creating. here i'm able to use the controllers. I'm not sure how my original website was created during the initial times but the same code is not working here.
I tried adding some packages and .dll files related to Microsoft Ajax but still unable to get.
Currently im getting output like the below
Error: 'respond' is not a valid script name. The name must end in '.js'.
<asp:ImageButton ID="ImageButton3" runat="server" Height="25px" ImageUrl="images/test_1.png" OnClick="ImageButton3_Click" style="margin-bottom: -7px" Width="25px" />
<label style="margin-left:10px;">To: </label>
<asp:TextBox ID="TextBox4" CssClass="tbclass" runat="server" Height="24px" ReadOnly="True"></asp:TextBox>
<asp:ImageButton ID="ImageButton4" runat="server" Height="25px" ImageUrl="images/test_1.png" OnClick="ImageButton4_Click" style="margin-bottom: -7px" Width="25px" />
<label style="margin-left:10px;">Mettings: </label>
<asp:dropdownlist runat="server" id="meeting_list_m">
<asp:listitem text="--Select--" value="1"></asp:listitem>
<asp:listitem text="All Hands Meeting" value="2"></asp:listitem>
</asp:dropdownlist>
<asp:Button runat="server" ID="bclear_m" Text="Clear" CssClass="go_sub" onClick="bclear_m_Click" BorderColor="#0066FF" BorderWidth="0px" ForeColor="White" />
<asp:Button runat="server" ID="go_m" Text="Search" CssClass="go_sub" onClick="go_m_Click" BorderColor="#0066FF" BorderWidth="0px" ForeColor="White" />
<button id="add_button1" class="add_sub" type="button" data-toggle="modal" data-target="#myModal2">Add</button>
<asp:Calendar CssClass="calender1_style" ID="Calendar3" runat="server" BackColor="White" BorderColor="White" BorderWidth="1px" Font-Names="Verdana" Font-Size="9pt" ForeColor="Black" Height="190px" OnDayRender="Calendar1_DayRender" OnSelectionChanged="Calendar3_SelectionChanged" Width="280px" NextPrevFormat="ShortMonth">
<DayHeaderStyle Font-Bold="True" Font-Size="8pt" HorizontalAlign="Center" VerticalAlign="Middle" />
<NextPrevStyle Font-Size="8pt" ForeColor="#333333" Font-Bold="True" VerticalAlign="Bottom" />
<OtherMonthDayStyle ForeColor="#999999" />
<SelectedDayStyle BackColor="#333399" ForeColor="White" />
<TitleStyle CssClass="align-left" BackColor="White" Font-Bold="True" Font-Size="12pt" ForeColor="#333399" BorderColor="#CC3399" BorderWidth="0px" HorizontalAlign="Center" VerticalAlign="Middle" />
<TodayDayStyle BackColor="#CCCCCC" />
</asp:Calendar>
<asp:Calendar CssClass="calender2_style" ID="Calendar4" runat="server" BackColor="White" BorderColor="White" BorderWidth="1px" Font-Names="Verdana" Font-Size="9pt" ForeColor="Black" Height="190px" OnDayRender="Calendar1_DayRender" OnSelectionChanged="Calendar4_SelectionChanged" Width="280px" NextPrevFormat="ShortMonth">
<DayHeaderStyle Font-Bold="True" Font-Size="8pt" HorizontalAlign="Center" VerticalAlign="Middle" />
<NextPrevStyle Font-Size="8pt" ForeColor="#333333" Font-Bold="True" VerticalAlign="Bottom" />
<OtherMonthDayStyle ForeColor="#999999" />
<SelectedDayStyle BackColor="#333399" ForeColor="White" />
<TitleStyle CssClass="align-left" BackColor="White" Font-Bold="True" Font-Size="12pt" ForeColor="#333399" BorderColor="#CC3399" BorderWidth="0px" HorizontalAlign="Center" VerticalAlign="Middle" />
<TodayDayStyle BackColor="#CCCCCC" />
</asp:Calendar>
</ContentTemplate>
</asp:UpdatePanel>
I am not sure about the exact solution. First check did you make some changes in bundles.config file. Please share more details or code possible. Also, find this link if helpful
'jquery' is not a valid script name. The name must end in '.js'
I want to turn paging off on a gridview, however, I can't seem to turn it off and I don't understand hwy it is on to begin with.
This seems like such a basic issue, but I can't seem to find anyone having the same issue. I can find plenty of people having issues in turning paging on, but no one turning it off.
ASP.Net Code
<asp:TabContainer ID="tcQuestions" runat="server" Width="100%" ActiveTabIndex="2">
<asp:TabPanel ID="tpAll" runat="server" HeaderText="All Questions" ScrollBars="None">
<ContentTemplate>
<asp:UpdatePanel ID="upAll" runat="server">
<ContentTemplate>
<asp:GridView ID="gvAllQuestions" runat="server" DataSourceID="sdsQuestions" AutoGenerateColumns="False" AllowPaging="False" Width="100%">
<Columns>
<asp:HyperLinkField DataTextField="QuestionRef" HeaderText="Ref" DataNavigateUrlFields="FkSection,QuestionID" DataNavigateUrlFormatString="questions/{0}/{1}">
<HeaderStyle Wrap="False" />
<ItemStyle Wrap="False" />
</asp:HyperLinkField>
<asp:BoundField DataField="QuestionText" HeaderText="Question" />
<asp:BoundField DataField="Period" HeaderText="Frequency">
<HeaderStyle Wrap="False" />
<ItemStyle Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="ValidFrom" HeaderText="Start From" DataFormatString="{0:dd MMM yy}">
<HeaderStyle Wrap="False" />
<ItemStyle Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="ObsoleteDate" HeaderText="Next Review" DataFormatString="{0:dd MMM yy}">
<HeaderStyle Wrap="False" />
<ItemStyle Wrap="False" />
</asp:BoundField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="sdsQuestions" runat="server"
ConnectionString="<%$ ConnectionStrings:ApplicationConnectionString %>"
SelectCommand="SELECT QuestionID, QuestionRef, QuestionText, FkSection, Period, ValidFrom, ObsoleteDate FROM Questions WHERE [FkSection] = #SectionID ORDER BY Obsolete, ObsoleteDate Desc">
<SelectParameters>
<asp:ControlParameter ControlID="ddlSections" Name="SectionID" />
</SelectParameters>
</asp:SqlDataSource>
</ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</asp:TabPanel>
There is no code behind affecting the gridview.
Overview:
I have two text boxes at the top of this form for inputting a beginning/ending date.
In the middle of the form I have a gridview that is populated with rows based on those dates.
At the bottom of the form I have a report generated based on which row is selected in the grid.
I selected the BeginningDate and the EndingDate and the gridview becomes populated (working). When I click the "Select" button on a row in the grid something is happening that makes it break. The row isn't selected. I know this because the CSS thats usually applied (by default) to a selected row in the gridview is not applied.
Additionally in the code-behind I'm setting...
lblGridError.Text = gridJobsReport.SelectedIndex.ToString()
The page load even has the same code, so the label reads "-1" when the page loads but never changes when I click the select buttons on the gridview. Something is breaking my Async postbacks. I wish I understood viewstate better, I'm always suspicious of it being the culprit but honestly I have no idea.
<%# Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="BidReport.aspx.vb" Inherits="BidReport" %>
<%# Register assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" namespace="Microsoft.Reporting.WebForms" tagprefix="rsweb" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
<ajaxToolkit:ToolkitScriptManager ID="tsmgrJobsReport" runat="server"
CombineScripts="True">
</ajaxToolkit:ToolkitScriptManager>
<p>
Enter a date range to populate the Jobs Grid.</p>
<asp:UpdatePanel ID="uPanelForm" runat="server">
<ContentTemplate>
<table>
<tr>
<td style="text-align: right">
<asp:Label ID="lblBeginningDate" runat="server" Text="Beginning Date:"></asp:Label></td>
<td>
<asp:TextBox ID="txtBeginningDate" runat="server" AutoPostBack="True"
CausesValidation="True"></asp:TextBox>
<ajaxToolkit:CalendarExtender ID="txtBeginningDate_CalendarExtender"
runat="server"
TargetControlID="txtBeginningDate">
</ajaxToolkit:CalendarExtender>
</td>
<td>
<asp:RequiredFieldValidator ID="rfvBeginningdate" runat="server"
ControlToValidate="txtBeginningDate"
ErrorMessage="You must enter the Beginning Date" Font-Bold="True"
ForeColor="Red">*</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="revBeginningDate" runat="server"
ControlToValidate="txtBeginningDate"
ErrorMessage="Posted Date must be in the format "DD/MM/YYYY""
Font-Bold="True" ForeColor="Red"
ValidationExpression="^([1-9]|1[012])/([1-9]|[12][0-9]|3[01])/(20\d\d)$">*</asp:RegularExpressionValidator>
</td>
<td rowspan="2">
<asp:CompareValidator ID="cvBeginDateLTEndDate" runat="server"
ControlToCompare="txtEndingDate" ControlToValidate="txtBeginningDate"
ErrorMessage="Beginning Date must be earlier than the Ending Date."
Font-Bold="True" ForeColor="Red" Operator="LessThan">*</asp:CompareValidator>
</td>
</tr>
<tr>
<td style="text-align: right">
<asp:Label ID="lblEndingDate" runat="server" Text="Ending Date:"></asp:Label></td>
<td>
<asp:TextBox ID="txtEndingDate" runat="server" AutoPostBack="True"
CausesValidation="True"></asp:TextBox>
<ajaxToolkit:CalendarExtender ID="txtEndingDate_CalendarExtender"
runat="server" TargetControlID="txtEndingDate">
</ajaxToolkit:CalendarExtender>
</td>
<td>
<asp:RequiredFieldValidator ID="rfvEndingDate" runat="server"
ControlToValidate="txtEndingDate"
ErrorMessage="You must enter the EndingDate Date" Font-Bold="True"
ForeColor="Red">*</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="revEndingDate" runat="server"
ControlToValidate="txtEndingDate"
ErrorMessage="Posted Date must be in the format "DD/MM/YYYY""
Font-Bold="True" ForeColor="Red"
ValidationExpression="^([1-9]|1[012])/([1-9]|[12][0-9]|3[01])/(20\d\d)$">*</asp:RegularExpressionValidator>
</td>
</tr>
</table>
<asp:ValidationSummary ID="valsumDates" runat="server" ForeColor="Red" />
<p>Click or Tap the "SELECT" button in the right column next to the Job you want and
a report will be generated below.</p>
<asp:GridView ID="gridJobsReport" runat="server" AutoGenerateColumns="False"
CellPadding="4" DataKeyNames="PostingID" DataSourceID="sqlDSReportGrid"
ForeColor="#333333" GridLines="Horizontal"
ShowHeaderWhenEmpty="True" Width="100%">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:BoundField DataField="PostingID" HeaderText="PostingID" ReadOnly="True"
SortExpression="PostingID" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="Department" HeaderText="Department"
SortExpression="Department" />
<asp:BoundField DataField="JobName" HeaderText="JobName"
SortExpression="JobName" />
<asp:BoundField DataField="Shift" HeaderText="Shift" SortExpression="Shift" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="Needs" HeaderText="Needs"
SortExpression="Needs" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="PostedDate" HeaderText="PostedDate"
SortExpression="PostedDate" DataFormatString="{0:d}" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="PostedTime" HeaderText="Time"
SortExpression="PostedTime" DataFormatString="{0:t}" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="ClosingDate" HeaderText="ClosingDate"
SortExpression="ClosingDate" DataFormatString="{0:d}" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="ClosingTime" HeaderText="Time"
SortExpression="ClosingTime" DataFormatString="{0:t}" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:CommandField ButtonType="Button" CausesValidation="True"
ShowSelectButton="true" />
</Columns>
<EditRowStyle BackColor="#999999" />
<EmptyDataRowStyle HorizontalAlign="Center" />
<EmptyDataTemplate>
There is currently no data to display based on the date range provided.
</EmptyDataTemplate>
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
<br />
<asp:Label ID="lblGridError" runat="server"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
<ajaxToolkit:UpdatePanelAnimationExtender ID="uPanelForm_UpdatePanelAnimationExtender"
runat="server" TargetControlID="uPanelForm">
</ajaxToolkit:UpdatePanelAnimationExtender>
<p>You can print or save the report using the buttons at the top of the report.</p>
<asp:UpdatePanel ID="uPanelJobsReport" runat="server">
<ContentTemplate>
<rsweb:ReportViewer ID="rvJobsReport" runat="server" Width="100%">
</rsweb:ReportViewer>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="gridJobsReport"
EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
<asp:SqlDataSource ID="sqlDSReportGrid" runat="server"
ConnectionString="<%$ ConnectionStrings:JobsDB %>"
SelectCommand="SELECT dbo.tblJobPostings.PostingID, dbo.tblDepartments.Department, dbo.tblJobs.JobName,
dbo.tblJobPostings.Shift, dbo.tblJobPostings.Needs, dbo.tblJobPostings.PostedDate,
dbo.tblJobPostings.PostedTime, dbo.tblJobPostings.ClosingDate, dbo.tblJobPostings.ClosingTime
FROM dbo.tblJobPostings
INNER JOIN dbo.tblJobs ON dbo.tblJobPostings.JobID = dbo.tblJobs.JobID
INNER JOIN dbo.tblDepartments ON dbo.tblJobPostings.DeptID = dbo.tblDepartments.DeptID
WHERE dbo.tblJobPostings.ClosingDate >= #BeginningDate
AND dbo.tblJobPostings.ClosingDate <= #EndingDate
ORDER BY dbo.tblJobPostings.ClosingDate Asc">
<SelectParameters>
<asp:ControlParameter ControlID="txtBeginningDate" Name="BeginningDate"
PropertyName="Text" ConvertEmptyStringToNull="False" DefaultValue="" />
<asp:ControlParameter ControlID="txtEndingDate" Name="EndingDate"
PropertyName="Text" ConvertEmptyStringToNull="False" DefaultValue="" />
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="sqlDSJobReport" runat="server"></asp:SqlDataSource>
</asp:Content>
I really don't understand why this worked, but I decided to try handling the dates manually with session variables and its working perfectly now. It doesn't matter if I mess with the session state on the update panels or any of the form elements it seems to work no matter what now.
I guess that after the initial asyncpostback the sqldatasource wasn't reading the values in the textboxes, or something. If anyone can explain what was going on in another "Answer Question" section I'll accept it.
If Page.IsPostBack Then
Session("sBeginningDate") = txtBeginningDate.Text
Sessoin("sEndingDate") = txtEndingDate.Text
txtBeginningDate.Text = Session("sBeginningdate")
txtEndingDate.Text = Session("sEndingDate")
Else
Session("sBeginningDate") = Now().AddDays(-14)
Session("sEndingDate") = Now()
txtBeginningDate.Text = Session("sBeginningDate").ToShortDateString
txtEndingDate.Text = Session("sEndingDate").ToShortDateString
End If
I added 3 updatepanel on a aspx page.Two updatepanel includes gridview.And i make gridview paging.two buttons fill this gridviews when clicked.I set both of them triggers and conditional state.Third updatepanel includes textbox.And i set updatemode conditional,triggers third button.
That my question,when i click firstly third button i select checked datafield from gridview,run succesfully.
But when i click after one clicked,third updatepanel and gridview paging is not working.
<asp:UpdatePanel ID="UpdatePanelWorkFLow" runat="server">
<%--<Triggers>
<asp:PostBackTrigger ControlID="btnGenerate" />
</Triggers>--%>
<ContentTemplate>
<asp:GridView ID="GridWorkFlow" runat="server" AllowPaging="True" AutoGenerateColumns="False"
EnableSortingAndPagingCallbacks="false" CellPadding="4" ForeColor="#333333" GridLines="None"
OnPageIndexChanging="GridWorkFlow_PageIndexChanging">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:TemplateField ShowHeader="true" HeaderText="SeƧ">
<ItemTemplate>
<asp:CheckBox ID="checkWorkFlow" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField Visible="False">
<ItemTemplate>
<asp:Label ID="labelWorkFlowId" runat="server" Text='<%# Eval("WorkFlowId")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="WorkFlow Adi">
<ItemTemplate>
<asp:Label ID="labelWorkFlowName" runat="server" Text='<%# Bind("Name") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Birincil Entity Adi">
<ItemTemplate>
<asp:Label ID="labelPrimaryEntity" runat="server" Text='<%# Bind("PrimaryEntity") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField Visible="true" HeaderText="Durum AƧiklamasi">
<ItemTemplate>
<asp:Label ID="labelWorkFlowStaus" runat="server" Text='<%# GetStatusCodeText(DataBinder.Eval(Container.DataItem,"StatusCode"))%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnWorkFLow" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
my gridview paging code
WorkFlowDataBind();
GridWorkFlow.PageIndex = e.NewPageIndex;
GridWorkFlow.DataBind();
my third button code
string userQueryId = GetUserQueryId();
string userqueryName = GetUserQueryName();
string workFlowId = GetWorkFlowId();
string primaryEntityName = GetWorkFlowPrimaryEntity();
GetWorkFlowName();
my one and second button when clicked load gridview
Datatable dtUserQuery=GetDataTable();
GridUserQuery.DataSource = dtUserQuery;
GridUserQuery.DataBind()
How can i fix.
Logic is .. If you have one or more update panel in the same page then properties of all update panel should be same such as if update panel data are dependency on each other
Update Mode : Always
EnableViewState : true(if you are using it)
Or you can explicitly update the Update panel when mode is conditional
Let us say you have two update panel like up1 and up2.
You have placed the label in the up1 and the other form or button placed in the up2.
Now on the click event in the up2, label placed in the up1 should be updated without loading the full page. Set the following stuffs
Set EnableParitialRendering ='True'(Script Manager)
Set Update Mode :Conditional(up1)
Set Update Mode : Always (up2). All set up done here. On click of a button in the up2, do your work and call up1.Update(); That's all.
Hi
I'm new to ajax.
I'm working on visual studio 2005. I install the ajax Min4setup and I add the control toolkit to the controls toolbar.
I created a new website Ajax-Enabled then I add the existing items (all the page) from the old web site to the new one.
I wrote the code below in the page.aspx and the other code in page.aspx.vb but nothing happens, the timer event is not firing.
Code:
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:Timer ID="Timer1" runat="server" OnTick="Timer1_Tick" Interval="8000" Enabled="true">
</asp:Timer>
<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Always" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text="test" />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4"
DataSourceID="SqlDataSource1" ForeColor="#333333" GridLines="None" Width="616px" BorderStyle="Outset">
<RowStyle BackColor="#EFF3FB" />
<Columns>
<asp:BoundField DataField="Sender" HeaderText="Sender"
SortExpression="MO_NICKNAME_SOURCE_LOG_HIS" />
<asp:BoundField DataField="DataChat" HeaderText="Conversation" SortExpression="DataChat" />
<asp:TemplateField HeaderText="Date" SortExpression="DATETIMEIN_LOG_HIS">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("DATETIMEIN_LOG_HIS") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("DATETIMEIN_LOG_HIS") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#2461BF" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:OfflineChat_ConnectionString %>"
SelectCommand="SP_GET_OFFLINE_USER_CHAT" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:SessionParameter Name="MO_OFFLINEUSER" SessionField="ID" Type="String" />
<asp:QueryStringParameter Name="MO_NICKNAME_REALUSER" QueryStringField="realuserNick"
Type="String" />
</SelectParameters>
</asp:SqlDataSource>
</ContentTemplate>
</asp:UpdatePanel>
Protected Sub Timer1_Tick(ByVal sender As Object, ByVal e As EventArgs)
{
Label1.Text = "Grid Refreshed at: "
'& DateTime.Now.ToString
GridView1.DataBind()
UpdatePanel1.Update();
}
Any idea or suggestion will be highly appreciated.
Best Regards,
Start the timer with timer1.Start().
Clear the GridView, set GridView1.DataSet = null and reload the Bindings.