I have following code in .aspx
<asp:UpdatePanel ID="upnGrid" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Repeater ID="rpt1" runat="server" OnItemDataBound="rpt1_ItemDataBound">
<ItemTemplate>
<table width="100%">
<tr>
<td align="right" width="25%">
<asp:Label ID="lbl1" Font-Bold="true" Font-Size="16px" Text=' <%# DataBinder.Eval(Container.DataItem,"Name") %>'
runat="server" />
</td>
<td>
<asp:HiddenField ID="hdn1" Value='<%# DataBinder.Eval(Container.DataItem, "Length") %>'
runat="server" />
</td>
<td>
<asp:TextBox ID="txt1" Font-Size="16px" Text='<%# DataBinder.Eval(Container.DataItem, "Value") %>'
AutoPostBack="true" Width="100px" OnTextChanged="txt1_TextChanged" runat="server" onkeydown="javascript:return OntxtEnter(event);"/>
</td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
</ContentTemplate>
<%--<Triggers>
<asp:AsyncPostBackTrigger ControlID="rpt1"/>
</Triggers>--%>
</asp:UpdatePanel>
code for UpdateProgress is at the end of aspx -
<asp:Panel ID="UpdateProgressPanel" runat="server">
<center>
<asp:UpdateProgress ID="UpdateProgress2" runat="server" AssociatedUpdatePanelID="upnGrid"
DynamicLayout="true">
<ProgressTemplate>
<img src="../Images/loading.gif" alt="">
</ProgressTemplate>
</asp:UpdateProgress>
</center>
</asp:Panel>
<ajaxtoolkit:modalpopupextender id="ModalProgress" runat="server" targetcontrolid="UpdateProgressPanel"
popupcontrolid="UpdateProgress2" dropshadow="false" backgroundcssclass="modalBackground">
</ajaxtoolkit:modalpopupextender>
As suggested by some answers I made AsyncPostBackTrigger to be registered in code behind, like -
var control = e.Item.FindControl("txt1");
ScriptManager.GetCurrent(Page).RegisterAsyncPostBackControl(control);
I am not getting, why it is not working.
Please suggest.
Edit
I tried putting only required textbox in UpdatePanel, It is showing following error
'System.Web.UI.Control' does not contain a definition for 'DataItem' and no extension method 'DataItem' accepting a first argument of type 'System.Web.UI.Control' could be found (are you missing a using directive or an assembly reference?)
Try modifying your UpdateProgress control as shown below:
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
<ProgressTemplate>
<asp:Panel ID="Panel1" runat="server">
<asp:Panel ID="Panel2" runat="server">
<asp:ImageButton ID="ibProgress" runat="server" ImageUrl="~/Images/progress.gif"
Visible="true" />Loading...
</asp:Panel>
</asp:Panel>
</ProgressTemplate>
</asp:UpdateProgress>
You cannot use it in such a way. Because inside the repeater the TextBox ID is different.You have to follow different mechanism.
Related
I have two Update Panels in an aspx page and one ModalPopupExtender inside each of them. The problem I am facing is that, I have set the Visible property to false in the aspx page and set it to True when it needs to be displayed. But the UpdatePanel is not showing up even though I have set Visible=True property.
aspx code:
<%--Request closed --%>
<asp:UpdatePanel ID="udpModalReqClose" runat="server" Visible="false">
<ContentTemplate>
<div style="display:none">
<asp:Button ID="btnDummyButton_ReqClose" UseSubmitBehavior="true" runat="server" Text="DummyButton" Style="display: none;" />
</div>
<asp:Panel ID="pnlCloseReq" runat="server" BackColor="White" BorderStyle="Solid" BorderColor="Black" BorderWidth="1px">
<div>
<table id="Table24" runat="server" border="0" cellpadding="4" cellspacing="10" width="400px">
<tr>
<td align="center">
<asp:Label ID="lblcloseSuccessOPR" runat="server" Font-Bold="true" ForeColor="Red" />
</td>
</tr>
<tr>
<td style="height: 5px;"></td>
</tr>
<tr>
<td align="center">
<asp:Button ID="btn_okclose" runat="server" SkinID="btnSearch" CssClass="btnSearch" OnClick="btnPOCPIRedirect_Click"
CausesValidation="false" align="center" Text="OK" Width="65px" />
</td>
</tr>
<tr>
<td style="height: 5px;"></td>
</tr>
</table>
</div>
</asp:Panel>
<cc1:ModalPopupExtender ID="mpeClosedSuccess" runat="server" PopupControlID="pnlCloseReq" TargetControlID="btnDummyButton_ReqClose"
BackgroundCssClass="modalPopup1" DropShadow="true" BehaviorID="mpe">
</cc1:ModalPopupExtender>
</ContentTemplate>
</asp:UpdatePanel>
<%--Request declined --%>
<asp:UpdatePanel ID="udpModalReqDecline" runat="server" Visible="false">
<ContentTemplate>
<div style="display:none">
<asp:Button ID="btnDummyButton_ReqDecline" UseSubmitBehavior="true" runat="server" Text="DummyButton" Style="display: none;" />
</div>
<asp:Panel ID="pnlRequestDecline" runat="server" BackColor="White" BorderStyle="Solid" BorderColor="Black" BorderWidth="1px">
<div>
<table id="Table17" runat="server" border="0" cellpadding="4" cellspacing="10" width="400px">
<tr>
<td align="center">
<asp:Label ID="lblRequestDecline" runat="server" Font-Bold="true" ForeColor="Red" />
</td>
</tr>
<tr>
<td style="height: 5px;"></td>
</tr>
<tr>
<td align="center">
<asp:Button ID="Button4" runat="server" SkinID="btnSearch" CssClass="btnSearch" OnClick="btnPOCPIRedirect_Click"
CausesValidation="false" align="center" Text="OK" Width="65px" />
</td>
</tr>
<tr>
<td style="height: 5px;"></td>
</tr>
</table>
</div>
</asp:Panel>
<cc1:ModalPopupExtender ID="mpeRequestDecline" runat="server" PopupControlID="pnlRequestDecline" TargetControlID="btnDummyButton_ReqDecline"
BackgroundCssClass="modalPopup1" DropShadow="true" BehaviorID="mpe">
</cc1:ModalPopupExtender>
</ContentTemplate>
</asp:UpdatePanel>
Link buttons which triggers the modalpopup in aspx:
<ItemTemplate>
<asp:LinkButton ID="LinkButton3" OnClick="lnkCloseReleaseHL" runat="server"
Text="Close"></asp:LinkButton>
</ItemTemplate>
<asp:TemplateColumn HeaderText="Decline">
<ItemTemplate>
<asp:LinkButton ID="lnkDeclineHLRelease" runat="server" OnClick="lnkDeclineHLRelease_Click">Decline All</asp:LinkButton>
</ItemTemplate>
Code behind:
public void lnkCloseReleaseHL(object sender, System.EventArgs e)
{
udpModalReqClose.Visible = true;
string successMsg = "Request has been closed Succesfully.";
lblcloseSuccessOPR.Text = successMsg;
mpeClosedSuccess.Show();
}
protected void lnkDeclineHLRelease_Click(object sender, EventArgs e)
{
udpModalReqDecline.Visible = true;
string successMsg = "Request has been declined.";
lblRequestDecline.Text = successMsg;
mpeRequestDecline.Show();
}
If I do not set the Visible=False property in the aspx page, one of the ModalPopup is shown on the webpage, blank with the 'OK' button I have inserted in the popup.
Also, if I have just one UpdatePanel in my aspx page, the popup works perfectly fine without setting Visible property. Once I add another UpdatePanel below it, this problem occurs(screenshot in the link), where the panel with 'OK' button is displayed on page load.
Panel appearing on page with the 'OK' button
I tried searching for every possible solutions on the web but nothing has helped me. If someone can please guide me how I can resolve this, it would be of great help. I just want to know how I can make multiple UpdatePanels work without having this issue.
I'm not sure, but you can try using
style="display:none"
instead of
Visible="false"
Currently in my visual WebPart Contains update panel , but it not working, it post back the whole page
my code
My .aspx code
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div>
<div class="leftSection">
<asp:DropDownList ID="ddlYear" runat="server" AutoPostBack="True">
<asp:ListItem Text="2015" Value="2015"></asp:ListItem>
<asp:ListItem Text="2016" Value="2016"></asp:ListItem>
</asp:DropDownList>
<div class="frmDate"><p>From</p>
<SharePoint:DateTimeControl ID="from" runat="server" DateOnly="True" AutoPostBack="true" MaxDate="8900-12-31" MinDate="2015-07-31" OnDateChanged="from_DateChanged" Calendar="1" IsRequiredField="true" ErrorMessage="Please Select From Date"/>
</div>
<div class="lastDate">
<p>
To
</p>
<SharePoint:DateTimeControl ID="to" runat="server" DateOnly="True" OnDateChanged="to_DateChanged" AutoPostBack="true" OnValueChangeClientScript="holidayDates()" IsRequiredField="true" ErrorMessage="Plaese Select To Date" />
</div>
</div>
<div class="rightSection">
<div id="testdiv" runat="server">
</div>
<asp:Label CssClass="hdn-lbl lblFromDate" ID="lblFromDate" runat="server" Text="Label"></asp:Label>
<asp:Label CssClass="hdn-lbl lblToDate" ID="lblToDate" runat="server" Text="Label"></asp:Label>
<asp:Label CssClass="hdn-lbl lblTotalHrs" ID="lblTotalHrs" runat="server" Text="Label"></asp:Label>
<asp:Button ID="save" runat="server" Text="SUBMIT" OnClientClick="return cal()" OnClick="save_Click" />
</div>
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="save" />
</Triggers>
</asp:UpdatePanel>
**after click on Submit Button it Post back total page **
Your save button is in your UpdatePanel by default you should use the ChildrenAsTriggers property of your UpdatePanel (set to true by default) and not AsyncPostBackTrigger.
Edit:
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
//...
</ContentTemplate>
</asp:UpdatePanel>
No external triggers just children as triggers, and default value as ChildrenAsTriggers is True equivalent to :
<asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true">
In continuation to my last question, I was suggested to use Repeater for displaying data fetched from SQL Db in horizontal layout.
https://stackoverflow.com/questions/25447351/asp-net-c-sharp-customized-gridview/25458682#25458682
As per suggestion I implemented a repeater control. The data was displayed in horizontal layout but only second column fetched from the DB.
How to get the first column too:
<asp:Repeater ID="RepDetails" runat="server">
<HeaderTemplate>
<asp:Literal ID="litRowStart" runat="server"></asp:Literal>
<td>
<asp:Label ID="lblExpID" runat="server" Text='<%#Eval("Exp_ID") %>' Font-Bold="true" />
</td>
<asp:Literal ID="litRowEnd" runat="server"></asp:Literal>
</HeaderTemplate>
<ItemTemplate>
<asp:Literal ID="litRowStart1" runat="server"></asp:Literal>
<td>
<asp:Label ID="lblExpAmt" runat="server" Text='<%#Eval("Amt_Allocated") %>' Font-Bold="true" />
</td>
<asp:Literal ID="litRowEnd1" runat="server"></asp:Literal>
</ItemTemplate>
</asp:Repeater>
Create your repeater like this:
<table>
<tr>
<asp:Repeater ID="repTest" runat="server">
<ItemTemplate>
<td>
<div>
<b>
<%#Eval("NameofColumnYOuWantToShowAsHeader") %>
</b>
</div>
<div>
<%#Eval("YourColumnValue") %>
</div>
</td>
</ItemTemplate>
</asp:Repeater>
</tr>
</table>
For more information about repeater:
Repeater Insert, Update, Delete in asp .net
Try this one using AlternateingItemTemplate:
<asp:Repeater ID="RepDetails" runat="server">
<ItemTemplate>
<td>
<asp:Literal ID="litRowStart" runat="server"></asp:Literal>
<asp:Label ID="lblExpID" runat="server" Text='<%#Eval("Exp_ID") %>' Font-Bold="true" />
<asp:Literal ID="litRowEnd" runat="server"></asp:Literal>
</td>
</ItemTemplate>
<AlternatingItemTemplate>
<td>
<asp:Literal ID="litRowStart1" runat="server"></asp:Literal>
<asp:Label ID="lblExpAmt" runat="server" Text='<%#Eval("Amt_Allocated") %>' Font-Bold="true" />
<asp:Literal ID="litRowEnd1" runat="server"></asp:Literal>
</td>
</AlternatingItemTemplate>
</asp:Repeater>
Assuming that you're getting 2 rows in your datasource.
I am trying to present a ajax progress bar when a delete button is clicked. This delete button will do things and will take time to process.. The delete button is within a repeater. The code is below:
<asp:UpdatePanel runat="server" ID="upDatePanel" UpdateMode="Conditional">
<ContentTemplate>
<asp:UpdateProgress runat="server" ID="UpdateProgress1" DynamicLayout="false" AssociatedUpdatePanelID="upDatePanel">
<ProgressTemplate>
<img id="Img1" runat="Server" src="~/Images/ajax-loader.gif" height="50" width="50" alt=""/>
</ProgressTemplate>
</asp:UpdateProgress>
<asp:Repeater ID="rptWork" runat="server" OnItemDataBound="rptWork_ItemDataBound">
<ItemTemplate>
<tr>
<td>
<asp:LinkButton ID="btnDelete" OnClick="btnDelete_Click" Text="Delete" runat="server" />
</td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr>
<td>
<asp:LinkButton ID="btnDelete" OnClick="btnDelete_Click" Text="Delete" runat="server"/>
</td>
</tr>
</AlternatingItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</ContentTemplate>
</asp:UpdatePanel>
I have put in a Thread.Sleep behind the delete button so when user clicks the progress bar appears however the process time takes abit longer. How can i make the progress bar stay on screen until the process is fully complete?
Try changing the UpdateMode="Always" to see if your getting page updates.
If you use conditional you will have to call Update yourself on the panel (not sure if your doing this??)
I've got an updatePanel and a button which triggered in it.
However, the button causes full postback instead of partial one.
Here's my Code:
<asp:Button ID="cEvent" runat="server" Text="צור יום" Width="80px"
Height="40px" Font-Size="Medium" onclick="cEvent_Click" CausesValidation="false"/>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel id = "updatePanel1" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="cEvent" EventName="Click"/>
</Triggers>
<ContentTemplate>
<div id="yesEve" runat="server" visible="false" style="width:95%; float:right; margin-left:5%; padding-top:20px; margin-bottom:20px;">
<table id="mytable" cellspacing="0" runat="server">
</table>
</div>
<div id="errorMsg" runat="server" visible="false" style="width:100%; text-align:center; float:right;">
<asp:label visible="true" ID="msg1" Font-Size="Medium" runat="server" Font-Bold="true" Text = "היום נמחק בהצלחה"></asp:label>
</div>
<div id="noEve" style="width:100%; padding-top:20px; float:right; text-align:center; margin-bottom:20px;" runat="server" visible="false">
<asp:label visible="true" ID="stamLabel" Font-Size="Medium" runat="server" Font-Bold="true" Text = "לא קיימים ימים פתוחים"></asp:label>
</div>
<asp:LinkButton ID ="remove" runat="server"></asp:LinkButton>
</ContentTemplate>
</asp:UpdatePanel>
I really need some help with that... i'm searching for hours all over the web to find an answer.
Thanks, Matan
In the code behind, you can try adding this line:
ScriptManager.GetCurrent(Page).RegisterPostBackControl(Button1);
There is nothing wrong with your code, you have a conflict somewhere with code(ClientIDs) you haven't show us or a JavaScript error breaking the page.
Here's a template for how to do this from a microsoft tutorial page:
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<fieldset>
<legend>UpdatePanel</legend>
<asp:Label ID="Label1" runat="server" Text="Panel created."></asp:Label><br />
</fieldset>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" />
</Triggers>
</asp:UpdatePanel>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
More information here:
microsoft tutorial