Showing posts with label updatepanel. Show all posts
Showing posts with label updatepanel. Show all posts

Wednesday, March 28, 2012

Updateprogress panel does not disappearing

Hello:

I have a web page with updatepanel and updateprogress. In each callback, updateprogress is showed with a panel "loading".

My problem is that, if I call other web page that opens one PDF in other window, updateprogress does not disappear from the screen:

In button click I have:

Response.Redirect(

"getDocument.aspx",false); //This page does not load on same explorer. It is opened in other window

I have tried adding code at bottom of this sentence, like "UpdatePanel1.Update();" or updateprogress1.visible=false, but no way.

Any ideas?

Thanks and regards

How you are loading the response in another explorer using Response.Redirect or are you opening the window from the client side?

refer this tutorial also:

http://ajax.asp.net/docs/tutorials/ProgrammingUpdateProgress.aspx

referDisplaying Update Progress Using Client Script in the above page.This describes how to intercepte page request manager lifecycle.


Hello and thanks by responding:

I am calling a web page called Getdocument.aspx from code behind (on rowcommand of datagrid). Not from client-side.

This web page "GetDocument.aspx", generates a PDF file with Response.binaryWrite and open it in a new browser. But caller page remains or must remain active.

Regards

UpdateProgress slow to show even if DisplayAfter=0

Hi, I have an UpdatePanel with a bunch of buttons, checkboxes and combobox and a GridView. I also have an UpdateProgress set with DisplayAfter="0". Sometimes, when it's taking a while to process the data, the UpdateProgress doesn't show up for 2-3 seconds and then gets displayed.

Is there any reason why it wouldn't always show up instantly? Is the trigger to show the UpdateProgress sent from server or client?

I use this CSS style for the updateProgress, could this be the problem (using IE7)?

#UpdateProgress1 {top:50%;width:100%;position:fixed;text-align: center;background:#dd2;}
Thanks,
Christian

Is there any image in Update Progress..


No images. Here is what I use :

<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1"
DisplayAfter="0">
<ProgressTemplate>
<div style="height: 50px">
<br />
Loading data ...
<br />
</div>
</ProgressTemplate>
</asp:UpdateProgress>


Try to give a 100 value may be 0 is some default


Thanks for the suggestion, but itt didn't help. It just took a little longer to show :)


what browser r u using?


I tried both IE6 and IE7


Do you have mupliple UpdatePanels?

Do you have the latest ASP.Net AJAX 1.0?


I have a single UpdatePanel that takes most of the page and I have ASP.NET AJAX 1.0 that I downloaded about 2 weeks ago.

UpdateProgress within treeView

hi...

i have treeView(populate onDemand) in updatePanel, and i want to add updateProgress animation or message, dynamically near to the selected node(parent node), someone have an idea how to implement that?

thanks...

Hi,
???Here are some sample codes about asp:TreeView working with asp:UpdateProgress for your reference.
??? <div>
<asp:UpdatePanel ID="UpdatePanel8" runat="server">
<ContentTemplate>
<asp:TreeView ID="tv" runat="server" OnSelectedNodeChanged="tv_SelectedNodeChanged">
<Nodes>
<asp:TreeNode Text="File" Value="File"></asp:TreeNode>
<asp:TreeNode Text="Edit" Value="Edit"></asp:TreeNode>
<asp:TreeNode Text="View" Value="View"></asp:TreeNode>
</Nodes>
</asp:TreeView>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress2" runat="server"
AssociatedUpdatePanelID="UpdatePanel8"
DisplayAfter="2000"
DynamicLayout="False">
<ProgressTemplate>
UpdatePanel1 is updating now!
<input type="button" id="AbortCallbackButton" value="Abort" onclick="AbortCallback()" />
</ProgressTemplate>
</asp:UpdateProgress>
<br />
This is text after the UpdatePanel and UpdateProgress controls.
<script type="text/javascript">
function AbortCallback()
{
Sys.WebForms.PageRequestManager.getInstance().abortPostBack();
}
</script>
</div
protected void tv_SelectedNodeChanged(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(10000);
}
Wish this can give you some helps.

UpdateProgressControl/UpdatePanel timeout

I have a main ASP.NET 2.0 web form (C# code-behind) that has an "inbox" that displays records from a database. The main web form has a AspTimer control and an UpdatePanel control that are used in concert to refresh the inbox every 2 minutes (120000ms) triggered by the timers Tick event. However, when a user creates a new record using another web form I am triggering an async refresh of the inbox (after the record is saved) by calling a javascript function (via ModalPopupExtender OnOkScript value) that detects the presence of a hidden button on the main form and firing it's click event which is handled as an asp:AsyncPostbackTrigger for the main web forms update panel. Everything works as designed, but from time to time after the remote page triggered refresh occurs the next timer refresh (Tick event) or other user initiated event (e.g. gridview row select, sort) will hang and result in an "Sys.WebForms.PageRequestManager TimeoutException: The Server request timed out."error. I am not sure if the remote page triggered refresh is confusing the AspTimer somehow or it is causing a collision of some sorts but any thoughts on the matter would be much appreciated.

Further details/update: Once I get the "Sys.WebForms.PageRequestManagerTimeoutException" error, I can consistentely get it to occur by clicking a button that triggers an async postback. It's as if the session has lost it's connection (note that this happens regardless if I am running against my local development machine (XP/IIS51) or our test server (2003/IIS6)). The very weird thing that is befuddling me is that if I use fiddler to watch the traffic to see what is going on it (the connection) will be magically restored and everything works fine again. There are no server side errors being thrown and JavaScript console in (NS/FireFox) does not show anything that would point me to a resolution.


Eureka!!! I figured out the problem. I have JavaScript methods that are called by my child forms when a user is clicking the "Close/Cancel" button that verify there are no unsaved changes before closing otherwise user is prompted to verify that they want to discard changes or not. If they confirmed that they wanted to close the web form I was simply calling window.close() but was not returning any value from the function which I think was a problem because the Close/Cancel button is located within the update panel (because the image changes depending on the scope of the form (e.g. new or view)) and thus despite closing the window I think the AJAX event lifecycle was being initiated but terminated abnormally because of the form closing. I added a "return false;" in my finally clause for all the functions that are used in the closing of a child web form and lo and behold my parent form no longer breaks (see example function below - added statement is bolded). I hope this solution also works for anyone else having a similar problem:

// Function Name: CloseVisitLog
// Function Purpose: Close the visit log form.
// Author: Michael Jensen
function CloseVisitLog(scope)
{
// put function within try-catch-finally block
try
{
// debug statement - set debug = true to view
if (debug) alert(">>Entered JavaScript:CloseVisitLog");

// declare local variables
var unsavedChanges = GetUnsavedChangesFlag();

if(scope == "new")
{
// make sure the user really wants to cancel
if (confirm("Are you sure you want to cancel creation of this visit log entry?"))
{
// close the window
window.close();
}
else
{
return false;
}
}
else if(scope == "view")
{
// if there are unsaved changes make sure the user really
// wants to close
if(unsavedChanges == "true")
{
if (confirm("There are unsaved changes, are you sure you want to close?"))
{
// close the window
window.close();
}
else
{
return false;
}
}
else
{
// close the window
window.close();
}
}
}
catch(ex)
{
var msg = "JavaScript:CloseVisitLog failed. ";
alert(msg + ex.messsage);
}
finally
{
// debug statement = set debug = true to view
if (debug) alert("<<Exiting JavaScript:CloseVisitLog");
// return false to prevent postback when window is closing
// otherwise parent form AJAX will break
return false;
}
}

Updating a DataList with UpdatePanel

I've been trying to update my DataList with UpdatePanel but it's not working.

What I have is a text field for a user to enter comments and a save button, along with a DataList control all in an UpdatePanel.

Data is being saved on the table when the save button is clicked but the DataList is not updated unless I refresh the browser. What am I doing wrong?

Here is my ASP code:

 <asp:UpdatePanel ID="UpdatePanel3" runat="server"> <ContentTemplate> <asp:Panel ID="PanelCommentBody" runat="server" CssClass="collapsePanel" Width="451px"><br /> <asp:TextBox ID="txtComments" runat="server" Height="45px" TextMode="MultiLine" Width="412px" ValidationGroup="cmnts" ></asp:TextBox><br /> <asp:Label ID="lblComment" runat="server" Text="" Font-Size="Small"></asp:Label> <asp:RequiredFieldValidator ID="RFVComments" runat="server" ErrorMessage="Please enter comment." ValidationGroup="cmnts" ControlToValidate="txtComments" Font-Size="Small" Width="154px"></asp:RequiredFieldValidator> <asp:Button ID="bttnPostComment" runat="server" Text="Post Comment" OnClick="bttnPostComment_Click" ValidationGroup="cmnts" Width="122px" /> <asp:Button ID="bttnDiscard" runat="server" Text="Discard" OnClick="bttnDiscard_Click" CausesValidation="false" /> </asp:Panel> <cc1:CollapsiblePanelExtender ID="CollapsiblePanelExtender2" runat="server" CollapseControlID="closeComment" ExpandControlID="closeComment" TargetControlID="PanelCommentBody" Collapsed="true" SuppressPostBack="true"> </cc1:CollapsiblePanelExtender> <asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1" Width="307px" Font-Size="Small"> <ItemTemplate> <strong>From: <a href="../Default.aspx?urnm=<%# Eval("UserName")%>"><asp:Label ID="FromLabel" runat="server" Font-Size="Small" Text='<%# Eval("UserName")%>'></asp:Label></a></strong> | Date Posted: <asp:Label ID="DateAddedLabel" runat="server" Text='<%# Eval("DateAdded", "{0:MMM dd, yy}")%>'></asp:Label><br /> <asp:Label ID="CommentLabel" runat="server" Text='<%# Eval("Comment")%>'></asp:Label><br /> <br /> </ItemTemplate> </asp:DataList><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MyDB%>" SelectCommand="SELECT [UserName], [Comment], [DateAdded] FROM [Comments] WHERE ([CL_Id] = @dotnet.itags.org.CL_Id) ORDER BY [DateAdded] DESC"> <SelectParameters> <asp:Parameter DefaultValue="1" Name="CL_Id" Type="String" /> </SelectParameters> </asp:SqlDataSource> </ContentTemplate> </asp:UpdatePanel>

Here is my Code Behind for the save button:

protected void bttnPostComment_Click(object sender, EventArgs e)
{
string flname = Request.QueryString["filename"];
flname = flname.Substring(0, flname.Length - 4);

if (User.Identity.IsAuthenticated)
{
MembershipUser myObject = Membership.GetUser();
string usrid = myObject.ProviderUserKey.ToString();
string usrname = User.Identity.Name;
string cmmnt1 = txtComments.Text;
string connStr = ConfigurationManager.ConnectionStrings["MyDB"].ConnectionString;
SqlConnection cnn = new SqlConnection(connStr);
SqlCommand cmd = new SqlCommand("INSERT INTO Comments (CL_Id, UserId, UserName, Comment) VALUES ('" + flname + "', '" + usrid + "', '" + usrname + "', '" + cmmnt1 +"')", cnn);
cnn.Open();
cmd.ExecuteNonQuery();
cnn.Close();
}
else
{
lblComment.Text = "You need to login to make comments";
}
}

----------

Thanks in advance,

Louis

1. Make UpdatePanel UpdateMode="Conditional"

2. after cnn.close(); write UpdatePanel3.Update()


Thanks siva sakki, I tried your suggestion but it still doesn't work.

What else can I try?

Louis


Updating a DataList with UpdatePanel

On Page_Load event, register DataList control

protected void Page_Load()
{
ScriptManager1.RegisterAsyncPostBackControl(DataList1);

DataList1.DataSource = this.SqlDataSource1;
DataList1.DataBind();
}


Thanks chetan, your suggestion might work. My problem is that I have the ScriptManger1 in the master page.

How can I reference this the way you have specified above?

Thank you,

Louis


I have tried the following to reference the the ScriptManger from content panel code behind:

ScriptManager.GetCurrent(this.Page).RegisterAsyncPostBackControl(DataList1);

is this the correct way of doing it? If it is my UpdatePanel still not updating. I have also removed this two lines:

//DataList1.DataSource = this.SqlDataSource1;
//DataList1.DataBind();

It is giving me this error:

Both DataSource and DataSourceID are defined on 'DataList1'. Remove one definition.

Do I need this two lines for it to work?

I am pulling my hair on this one.

Please help. Thanks again.

Louis


If you go back to the original code you submitted and add DataList1.DataBind() at the end of the button routine, you would probably achieve the results you want.

There is nothing to cause the DataList to rebind after the button event.

If you simply delete the UpdatePanel from the page, your code would not work either. As a rule, if doesn't work without Ajax, it won't work with it. The DataBinding event for the DataList has to run on the postback.


wrayx1 that did the trick.

Thank you soooo much!!!

Louis


Just do withDataList1.DataBind();

Let me know if this helps you


Okay, I have a similar question about updating using DataList. Will someone give me a hand on this. Here's what I have.

1<asp:ScriptManager ID="ScriptManager1" runat="server">2 </asp:ScriptManager>3<%--<asp:UpdatePanel ID="UpdatePanel1" runat="server">4 <ContentTemplate>--%>5 <asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True">6 <asp:ListItem Value="True">Approved</asp:ListItem>7 <asp:ListItem Value="False" Selected="True">Not Approved</asp:ListItem>8 </asp:RadioButtonList>9 <asp:SqlDataSource ID="sqlApproval" runat="server" ConnectionString="<%$ ConnectionStrings:myConnStr%>"10 SelectCommand="SELECT [frstName], [lstName], [dvlID], [mdlName], [mdnName], [degree1], [degree2], [year1], [year2], [sp_frstName], [sp_lstName], [sp_year1], [sp_year2], [sp_mdlName], [sp_mdnName], [sp_degree1], [sp_degree2], [approval] FROM [dvlStory] WHERE ([approval] = @.approval)"11 DeleteCommand="DELETE FROM [dvlStory] WHERE [dvlID] = @.dvlID"12 InsertCommand="INSERT INTO [dvlStory] ([frstName], [lstName], [mdlName], [mdnName], [degree1], [degree2], [year1], [year2], [sp_frstName], [sp_lstName], [sp_year1], [sp_year2], [sp_mdlName], [sp_mdnName], [sp_degree1], [sp_degree2], [approval]) VALUES (@.frstName, @.lstName, @.mdlName, @.mdnName, @.degree1, @.degree2, @.year1, @.year2, @.sp_frstName, @.sp_lstName, @.sp_year1, @.sp_year2, @.sp_mdlName, @.sp_mdnName, @.sp_degree1, @.sp_degree2, @.approval)"13 UpdateCommand="UPDATE [dvlStory] SET [frstName] = @.frstName, [lstName] = @.lstName, [mdlName] = @.mdlName, [mdnName] = @.mdnName, [degree1] = @.degree1, [degree2] = @.degree2, [year1] = @.year1, [year2] = @.year2, [sp_frstName] = @.sp_frstName, [sp_lstName] = @.sp_lstName, [sp_year1] = @.sp_year1, [sp_year2] = @.sp_year2, [sp_mdlName] = @.sp_mdlName, [sp_mdnName] = @.sp_mdnName, [sp_degree1] = @.sp_degree1, [sp_degree2] = @.sp_degree2, [approval] = @.approval WHERE [dvlID] = @.dvlID">14 <SelectParameters>15 <asp:ControlParameter ControlID="RadioButtonList1" Name="approval" PropertyName="SelectedValue"16 Type="Boolean" />17 </SelectParameters>18 <DeleteParameters>19 <asp:Parameter Name="dvlID" Type="Int32" />20 </DeleteParameters>21 <UpdateParameters>22 <asp:Parameter Name="frstName" Type="String" />23 <asp:Parameter Name="lstName" Type="String" />24 <asp:Parameter Name="mdlName" Type="String" />25 <asp:Parameter Name="mdnName" Type="String" />26 <asp:Parameter Name="degree1" Type="String" />27 <asp:Parameter Name="degree2" Type="String" />28 <asp:Parameter Name="year1" Type="Int32" />29 <asp:Parameter Name="year2" Type="Int32" />30 <asp:Parameter Name="sp_frstName" Type="String" />31 <asp:Parameter Name="sp_lstName" Type="String" />32 <asp:Parameter Name="sp_year1" Type="Int32" />33 <asp:Parameter Name="sp_year2" Type="Int32" />34 <asp:Parameter Name="sp_mdlName" Type="String" />35 <asp:Parameter Name="sp_mdnName" Type="String" />36 <asp:Parameter Name="sp_degree1" Type="String" />37 <asp:Parameter Name="sp_degree2" Type="String" />38 <asp:Parameter Name="approval" Type="Boolean" />39 <asp:Parameter Name="dvlID" Type="Int32" />40 </UpdateParameters>41 <InsertParameters>42 <asp:Parameter Name="frstName" Type="String" />43 <asp:Parameter Name="lstName" Type="String" />44 <asp:Parameter Name="mdlName" Type="String" />45 <asp:Parameter Name="mdnName" Type="String" />46 <asp:Parameter Name="degree1" Type="String" />47 <asp:Parameter Name="degree2" Type="String" />48 <asp:Parameter Name="year1" Type="Int32" />49 <asp:Parameter Name="year2" Type="Int32" />50 <asp:Parameter Name="sp_frstName" Type="String" />51 <asp:Parameter Name="sp_lstName" Type="String" />52 <asp:Parameter Name="sp_year1" Type="Int32" />53 <asp:Parameter Name="sp_year2" Type="Int32" />54 <asp:Parameter Name="sp_mdlName" Type="String" />55 <asp:Parameter Name="sp_mdnName" Type="String" />56 <asp:Parameter Name="sp_degree1" Type="String" />57 <asp:Parameter Name="sp_degree2" Type="String" />58 <asp:Parameter Name="approval" Type="Boolean" />59 </InsertParameters>60 </asp:SqlDataSource>61 <br />62 <asp:DataList ID="dltApproval" runat="server" BackColor="White" BorderColor="#999999"63 BorderStyle="None" BorderWidth="1px" CellPadding="3"64 GridLines="Vertical" RepeatColumns="3" RepeatDirection="Horizontal" Width="700px" DataSourceID="sqlApproval">65 <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />66 <SelectedItemStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />67 <ItemTemplate>68 <table border="0" cellpadding="2" cellspacing="0">69 <tr>70 <td>71 <asp:Label ID="frstNameLabel" runat="server" Text='<%# loadStory()%>'></asp:Label>72 </td>73 <td>74 <asp:CheckBox ID="chbApproval" runat="server" Checked='<%# Bind("approval")%>' />75 </td>76 </tr>77 </table>78 </ItemTemplate>79 <AlternatingItemStyle BackColor="Gainsboro" />80 <ItemStyle BackColor="#EEEEEE" ForeColor="Black" />81 <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />82 </asp:DataList>83<%-- </ContentTemplate>84 </asp:UpdatePanel>--%>85 <table border="0" cellpadding="5" cellspacing="0" width="700">86 <tr>87 <td style="width: 100px; text-align: center">88 <asp:Button ID="btnUpdate" runat="server" OnClick="btnUpdate_Click" Text="Update" /></td>89 <td style="width: 100px; text-align: center">90 <asp:Button ID="btnFinish" runat="server" OnClick="btnFinish_Click" Text="Finish" /></td>91 </tr>92 <>  

And here's the code behind:

1protected void Page_Load(object sender, EventArgs e)2 {34 }5protected string loadStory()6 {7//load the data in here and display to the lable control8return strInfoHolder.ToString() ;9 }10protected void btnUpdate_Click(object sender, EventArgs e)11 {12 sqlApproval.Update();13 dltApproval.DataBind();14 }15protected void btnFinish_Click(object sender, EventArgs e)16 {17 Response.Redirect("~/Admin/");18 }

The problem I have is that it's not updating. At the moment, I disabled the AJAX UpdatePanel to figure out the udpate first. All I wanted is to update the Approval checkbox to the sqlDataSource control. Noticed I used Bind instead of Eval for the checkbox control that way I was hoping that once I called the sqlApproval.Update() method, the approval checkbox will automatically update the database field. However, that is not so. Any help is appreciated.

Updating a FreeTextBox within an UpdatePanel

Hello everybody,

I'm working on a translation interface for a multilingual intranet. This leads me to use Rich TextBoxes such as FreeTextBox.

It is well known that there are issues about it when used with ajax.net, but I tried...


My issue:

I've got a page with three imbricated updatePanels. UpdatePanel1 contains both of the other update panels.

When updating these controls, I want a freeTextBox to get a text to translate.

But, not only does the FreeTextBox refuses to get the text, it also generates javascript errors that prevent me from openning an ajax modal popup.

I've tried to replace Freetextboxes by simple asp textboxes and this works fine... excepted as regards the fact that i can see all the html, and cannot put my text in form...

Coulds give me a hint to solve this? Do you know another rich text box with which i would have this issue?

Thanx a lot.

DART did the same thing, TinyMCE too... The only richTextBox I have tested which works is CuteEditor.

From what I've read, the issue comes from the focus on the textbox.

So no soultion for the moment.


Hi, I think I had the opposite problem to you. I could get the text by using .Text property but I couldn't set the text byassigning a new value to .Text.

I had to use the following code as a workaround : -

Private Sub SetEnoteText(ByVal strNotesAs String)Dim strScriptAs String =String.Format( _"$get('ctl00_maincontentarea_HeaderTabs_eNoteTab_eNoteText').value = '{0}';", _ strNotes.Replace(vbLf, "").Replace(vbCr, "")) strScript += "ctl00_maincontentarea_HeaderTabs_eNoteTab_eNoteText_Initialize(ctl00_maincontentarea_HeaderTabs_eNoteTab_eNoteText_editor, $get('ctl00_maincontentarea_HeaderTabs_eNoteTab_eNoteText'));" ScriptManager1.RegisterStartupScript(Me,Me.GetType(),"SETNOTE", strScript,True)End Sub
'ctl00_maincontentarea_HeaderTabs_eNoteTab_eNoteText' Being the ID of the FreeTextBox.
 
 

Monday, March 26, 2012

Updating a UpdatePanel from another form?

This may be a silly question, but since I'm a total newbie I have to ask.

If I have say 5 different UpdatePanels on a form and if I from the same form open another form (window.open('anotherform.aspx...')) for data entry is it possible to update one of the UpdatePanels on the main form? Or, to the triggers all have to be situated at the same form as the UpdatePanel?

Any help is apreciated!

Instead of window.open and design a new page for popup, you can design using modalpopupextender and you can refresh any panels from the same page.

Updating an UpdatePanel

Hello, I have just started using AJAX and ASP and could use some help with a problem I could not solve today.

Here is a link so you can check out my site setup...

http://opteron.dnsprotect.com/~verisol/HelpImage.bmp

LogSheetOperator.aspx is a content page to Site.Master and is the page that includes the AJAX ScriptManager. The VB code in this page adds the .ascx pages to the UpdatePanels of each tab.

NetWeightAuditUpdatePanel and CheckTimesUpdatePanel both contain a gridview. When the gridview in the NetWeightAuditUpdatePanel is updated, I want the CheckTimesUpdatePanel to refresh.

I made a simple test page that implements the Triggers feature of the update panel and successfully got that working with the Click method of a button. When I tried to apply that logic to the real project, it did not work. I'm guessing this is because of how the pages are structured.

Anyone have a solution or suggestions?

Thanks!
Matt


Off hand, i know there are many approaches out there, but have you considerd a single updatepanel hosting the tab containers which in turn host the dynamic ascx files.

You have the tab container hostin the tab panels which inturn hosts the updatepanels which inturn hosts the ascx files. cant 1 updatepanel provide you the support that you need.?


Daniel, thanks for that information. I just tried replacing all the update panels with a single update panel that encapsulated both Tab groups, but it still did not work. Since the content is on those .ascx pages, if I try and call a .Update() method inside the gridviews rowupdated event, it says that theUpdatePanelX.Update() is not defined, which makes sense because it is on a different page.

Any other ideas on how to get the UpdatePanel to Update?

Thanks!


what does "When the gridview in the NetWeightAuditUpdatePanel is updated" mean , are you doing some kind of editing here in the gridview or do you mean when the underlying data in updated?

i dont know if the following would be useful, but when i used ascx files sometimes i need to call some function or sub in the ascx's underlying codebehind to update the controls in the ascx.

What i do in that case is to create a public method mostly a sub, could be a function or property too. and have the hosting page call that public method of the ascx object instance. that way the ascx object will postback and the content of the ascx will update.

in your case you could explicitly call the "update" method of the ascx and let normal postback take care of the updating via the updatepanel as normal or you could go overboard and wire-up the public method of the ascx as an event handler of the rowupdated event.

So essentially you are not trying to call the .updatemethod of the updatepanel but instead trying to cause a postback in addition to firing an event in the "target" ascx that you want updated and you take it from there.

updating an updatepanel...

Hi.

I'm sure the update panel is not just a clever name, but, it isn't doing what it ways on the tin!!

UpdatePanel1: Houses a databound GridView
UpdatePanel2: TextBox1 and ListBox1.

I have a page with a search form on. The user submits search criteria which fire a conditional update of UpdatePanel1. The GridView re-binds itself perfectly! Now, I used to have some javascript which picked up the selected value of Listbox1 and dumped it out to TextBox1, it worked fine, until, I installed the latest release of the toolkit and now the javascript cannot find the form object.

No matter, I thought, I'll use an update panel and set it to conditional update and uses ListBox1.SelectedIndexChanged to fire the update, dumping the selected value into TextBox1. So I wrapped TextBox1 in UpdatePanel2 and run the code... nothing happened, until, I hit the search button which fires the update of UpdatePanel1. When I click this button both panels update?

So I thought I'd try putting ListBox1 outside of the UpdatePanel2... still no joy, exactly the same thing happened when the search button is clicked.

I then tried forcing the UpdatePanel2 to update in the code behind using, amazingly, UpdatePanel2.Update()... Guess what... nothing, until I hit the search button again.

I have double checked and both panels are setup as follows: UpdateMode="Conditional" ChildrenAsTriggers="False". My Script manager has Partial Rendering set to true. Both Update Panels have the correct triggers i.e UpdatePanel1 = Button1.click and UpdatePanel2 = ListBox1.SelectedIndexChanged

Anybody have any ideas? I can post the code up if required.

Thanks in advance.

I was able to recreate your example, with a listbox and textbox, populating the textbox on the listbox_SelectedIndexChanged event. At first, it would fire and fire and fire, but the textbox wouldn't update.

The kicker was changing ChildrenAsTriggers="True". See if that doesn't help.


Thanks Dugald.

I tried this but still no luck. Is your ListBox inside or outside the update panel?

I'm not convinced that the event is firing or not in al hoensty! I've tried adding an UpdateProgress template and adding sleep to the thread of 2 seconds but I still see nohting.

Just to confirm your setup.

ScriptManager: PartialRendering="True"
UpdatePanel: UpdateMode="Conditional" ChildrenAsTriggers="true "
ListBox: OnSelectedIndexChanged="ListBox1_SelectedIndexChanged"

?


Have you tried setting a breakpoint in the event code to verify the event is firing?

Here is the code for my simple test:

<%@. Page Language="C#" EnableViewState="true" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" EnablePartialRendering="true" runat="server"> </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="True" UpdateMode="Conditional"> <ContentTemplate> <asp:ListBox ID="ListBox1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ListBox1_SelectedIndexChanged"> <asp:ListItem>Alpha</asp:ListItem> <asp:ListItem>Bravo</asp:ListItem> </asp:ListBox> <asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Button" /><br /> <br /> <asp:TextBox ID="TxtTarget" runat="server" ForeColor="Black"></asp:TextBox> </ContentTemplate> </asp:UpdatePanel> <asp:Button ID="Button1" runat="server" Text="Full Postback" OnClick="Button1_Click2" /> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> </form></body></html>
using System;using System.Data;using System.Configuration;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;public partialclass _Default : System.Web.UI.Page {protected void Page_Load(object sender, EventArgs e) { }protected void Button1_Click1(object sender, EventArgs e) { }protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e) { TxtTarget.Text ="Changed";// ListBox1.SelectedValue; }protected void Button2_Click(object sender, EventArgs e) { TxtTarget.Text ="Pushed"; }protected void Button1_Click2(object sender, EventArgs e) { TxtTarget.Text ="Posted"; TextBox1.Text ="Posted"; }}

Ok, after adding a breakpoint on the ListBox1_SelectedIndexChanged event. I can see that the event is not even firing?
Try deleting the event and recreating it.

AHHHHHHHHH!!!!!!!!!!!!!!

Amazing what AutoPostBack="True" does!

Thanks for your help Dugald! Sorry for the Noob error...

Updating an UpdatePanel with Javascript

I've done a lot of googling to find a fix for this - I've found lots of posts about people using something similar however no one gives a clear example of how to do it.

I've created a cut down version of what we're trying to do and you can clearly see the problem with it if you load the test file.

Ok first we have an update panel with a literal and an asp:button with a server onclick function to change the literal text when pushed. Then we have a standard HTML button with a javascript command to click the asp:button. What happens is when the html button is outside the update panel the whole page posts back. When it's inside the update panel it looks as if the update panel is refreshed but the literal valuedoesn't change. I say that the update panel looks like it's being refreshed because previously we had an updateprogress control on this page and it was showing that it was updating.

Anyone that knows what's going on or can suggest another solution?

<%@dotnet.itags.org. Page Language="VB" %><script runat="server" >Sub Page_Load(ByVal SenderAs Object,ByVal eAs EventArgs)If Not Page.IsPostBackThenliTesting.Text ="before postback"End IfEnd SubProtected Sub btnUpdate_Click(ByVal senderAs Object,ByVal eAs System.EventArgs)liTesting.Text ="after postback"End Sub</script><!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" xml:lang="en"><head runat="server"><title>UpdatePanel Test</title></head><body><form runat="server"><asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" /><asp:UpdatePanel runat="server" ID="UpdatePanel1"><ContentTemplate><asp:Literal runat="server" id="liTesting" /><asp:Button ID="btnUpdate" runat="server" OnClick="btnUpdate_Click" text="asp button" /></ContentTemplate></asp:UpdatePanel><input type="button" onclick="javascript: document.getElementById('<%=btnUpdate.ClientID%>').click();" value="html button" /></form></body></html>

No one's encountered this before?

*shameless bump*


Not having any problems with your sample. It fires the event and no refresh happens.

the only thing I can see doing is a little tweaking of your js

onclick="javascript: $get('btnUpdate').click();"

Kodo, please excuse my ignorance, but what is the meaning and syntax of the $get function? I must admit I never saw it before...


$get is a crossbrowser version (more or less) of document.getElementByID that is introduced with ASP.NET AJAX. I love it.


Thanks a million. I guess I'll start using it.

Kodo - thanks for reminding me about the $get call - we've only just switched from atlas to microsoft ajax yesterday and I just upgraded the old code from <atlas:... to <asp:...

I just tried the example again and it turns out the refresh ONLY happens in Firefox (I'm using 1.5.0.8 currently). It must be something to do with how Firefox determines if a user clicks the button or if a script does.


I've been trying to do something similar using a LinkButton (not standard form button).

$get works great, but the click event is not accesible using firefox 2. Im guessing this is a security thing, the fox is throwing an error

Error: $get("lnkDoPostBack").click is not a function
Source File:http://localhost:1667/AjaxDigiguru/Display/ImageEdit.aspx
Line: 82

I made a mini workaround that posts the page back if you have firefox, rather than causing an error.

Dim strScriptAsString ="function UpdateThumbnail(x,y,w,h) { " & vbNewLine & _

" if($get('lnkDoPostBack').click){ " & vbNewLine & _" $get('lnkDoPostBack').click();} else {" & vbNewLine & _" document.forms[0].submit()}" & vbNewLine & _" }"

Is there a more elegant fix? I'd love to call an UpdatePanel from a javascript function cross browser. I'm sure theres a real solution, rather than a bodge.


Hi,

I was seeing the same complete page submit on the HTML button in FireFox 1.5. As a test I modified things to manually do a __PostBack() on the asp:button within the panel and that seems to work as expected (a partial page update):

<%@.PageLanguage="VB" %>
<scriptrunat="server"
Sub Page_Load(ByVal SenderAsObject,ByVal eAs EventArgs)

IfNot Page.IsPostBackThen
liTesting.Text ="before postback"
EndIf

EndSub

ProtectedSub btnUpdate_Click(ByVal senderAsObject,ByVal eAs System.EventArgs)

liTesting.Text ="after postback " & system.datetime.now().tostring()

EndSub

</script>

<!

DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml"xml:lang="en">
<headid="Head1"runat="server">
<title>UpdatePanel Test</title>
</head
<body
<formid="Form1"runat="server"
<asp:ScriptManagerID="ScriptManager1"runat="server"EnablePartialRendering="true"/
<scriptlanguage="javascript">
function htmlPostBack()
{
__doPostBack('<%=btnUpdate.ClientId%>','');
}
</script>

<

asp:UpdatePanelrunat="server"ID="UpdatePanel1">
<ContentTemplate>
<asp:Literalrunat="server"id="liTesting"/>
<asp:ButtonID="btnUpdate"runat="server"OnClick="btnUpdate_Click"text="asp button"/>
</ContentTemplate>
</asp:UpdatePanel>

<

inputtype="button"onclick="htmlPostBack();"value="html button"/
</form>
</body>
</html
Shawn


Cheers Shawn. Works a treat, but bear in mind that the documentation says it's unsupported, you might need to change it when they release the final version!

Updating an UpdatePanel through a LinkButton command generated by a repeater

Hi everybody,

I would like to refresh an update panel when I click on a Linkbutton generated by a repeater that looks like this:

<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
<ItemTemplate>
<li>
<asp:LinkButton ID="LinkButton1" runat="server" OnCommand="FilterByPrize" CommandName="filter" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "NameID")%>'>
<%# DataBinder.Eval(Container.DataItem, "Name")%> </asp:LinkButton>
</li>
</ItemTemplate>
</asp:Repeater>
The command called is the following:   
 protected void FilterByPrize(object sender, CommandEventArgs E){string connString ="connstring"; SqlConnection IVR =new SqlConnection(connString);string finalquery ="sqlquery " + E.CommandArgument.ToString() +" order by TimeStamp desc"; SqlDataSource2.SelectCommand = finalquery; SqlDataSource2.DataBind(); userData.DataBind();} 
The problem with this is that it reloads the whole page instead of only the update panel. Is there a way to refresh the updatepanel from a function in the c# code called from a linkbutton?
Thanks

MrClash,

The update panel has an Update() method that will do this. But I'm afraid that you are going to have register the linkbutton with the update panel. Take a look at this thread.

http://forums.asp.net/thread/1703456.aspx

Good luck! And feel free to provide some more details if this doesn't work.
Regards.

Updating an UpdatePanel only when certain item is clicked in Datalist

I have 2 UpdatePanels each with a Datalist in them. Here is my code:

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="DataList2" />
</Triggers>
<ContentTemplate>
<asp:DataList ID="DataList1" runat="server" DataSourceID="Ods1"BorderStyle="Solid" GridLines="Both" RepeatDirection="Horizontal">
<ItemTemplate>
<asp:ImageButton ID="ThumbImage1" runat="server"ImageUrl='<imagepath...>' />
</ItemTemplate>
</asp:DataList>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false">
<ContentTemplate>
<asp:DataList ID="DataList2" runat="server" RepeatColumns="4"DataSourceID="Ods2" BorderStyle="Solid" GridLines="Both"RepeatDirection="Horizontal" OnItemCommand="DataList2_ItemCommand"CellPadding="5">
<ItemTemplate>
<asp:ImageButton ID="ThumbImage2" runat="server"ImageUrl='<imagepath...>' CommandName="ThumbImage"CommandArgument='<passing the id...>' />
<br />
<asp:ImageButton ID="DeleteImage" runat="server"ImageUrl="images/delete.gif" CommandName="DeleteImage"CommandArgument='<passing the id...>' />
</ItemTemplate>
</asp:DataList>
</ContentTemplate>
</asp:UpdatePanel>

and the code in DataList2_ItemCommand is as follows:

protected void DataList2_ItemCommand(object source, DataListCommandEventArgs e)
{
if (e.CommandName == "DeleteImage")
{
//code to delete the image from database

...
this.DataList2.DataBind();
this.UpdatePanel2.Update();
}
else if (e.CommandName == "ThumbImage2")
{
//code to add the thumb image to the table attached to datalist1.
...
...
this.Datalist1.DataBind();
this.UpdatePanel1.Update();
}
}

As you can see in the above code, I want to update the UpdatePanel1 only when the imagebutton "ThumbImage2" is clicked and NOT when the imagebutton "DeleteImage" is clicked in Datalist2. But because Datalist2 is the cause of the AsyncPostBackTrigger for UpdatePanel1, it is updated when either one of the imagebuttons are clicked. Is there a way to change this?

Please help.

You don't want to set the datalist as the trigger, you want to set the individual ImageButtons as the triggers. Remove the triggers from UpdatePanel1, as well as the UpdateMode="Conditional".

<asp:UpdatePanelID="UpdatePanel1"runat="server">
<ContentTemplate>
...
</ContentTemplate>
</asp:UpdatePanel>

Then in the DataList2_ItemDatabound event, add the following:

ProtectedSub DataList2_ItemDataBound(ByVal senderAsObject,ByVal eAs System.Web.UI.WebControls.DataListItemEventArgs)Handles DataList2.ItemDataBound
Dim ibtnAs ImageButton =CType(e.Item.FindControl("ThumbImage2"), ImageButton)
Dim trggrAsNew AsyncPostBackTrigger
trggr.ControlID = ibtn.ClientID
trggr.EventName ="Click"
UpdatePanel1.Triggers.Add(trggr)
EndSub


In the ItemCommand event, I am executing some server side code for the imagebutton that was clicked in that specific row of datalist based on its id (which I retrieve using e.CommandArgument).

If I use the approach that you mentioned above, how do i retrieve the database id of the image clicked?

Thanks


DataList2.DataKeys.Item(e.Item.ItemIndex)


The solution you suggested works like a charm. I removed the datalist as the trigger & added the imagebutton as trigger in ItemDataBound event. Also, I still execute the server side code in ItemCommand event based on the which button clicked & everything works fine.

Thanks a ton.

Updating an UpdatePanel from another webpage.

I have an UpdatePanel on a page. This webpage opens up a new web page. Is it possible to force an update of the UpdatePanel on the first webpage from the second page?

hello.

yep, that should be possible. if your main problem is establishing the comunication from the child to the parent window, then take a look here:

http://www.javascriptkit.com/javatutors/remote2.shtml


But what can I call on the parent page to force a submit of the panel. Would I, for example, have to call the submit event of a button which in turn will submit the updatepanel or is there an event which I can call directly on the updatepanel itself? I don't really want to have to add an extra control to raise the submit event which would be visible to the user.

hello.

yes, that is the idea... you can add a button to the page and hide it (say, set it's css display to none). so, your parent page can expose a method that is responsible for calling the click methdo over that button (this method will be called from your child page).

Updating ContentPlaceHolder using UpdatePanel(like using frames)

Hi guys,

Is there a way to update the whole Content page without master page refreshing it self? like same effect as using frames or iframes in html.

I tried following, just simply placing script manager and wrapping ContentPlaceHolder with UpdatePanel, which didn't work.

Any suggestions?


<%@dotnet.itags.org. Master Language="C#" AutoEventWireup="true" CodeFile="Site.master.cs" Inherits="Site" %>
<html>
<head runat="server">
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager" runat="server"></asp:ScriptManager>
<div id="main"
<div id="titleBar">Title</div>

<div id="siteMenu">
<asp:Menu ID="Menu1" runat="server" SkinID="MenuBar" DataSourceID="SiteMapDataSource1" OnMenuItemClick="Menu1_MenuItemClick">
</asp:Menu>
</div>


<div id="content">

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate
<asp:contentplaceholder id="contents" runat="server"></asp:contentplaceholder>


</ContentTemplate>
</asp:UpdatePanel>
</div>


<div id="footer">footer</div
</div
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
</form>
</body>
</html>



Sorry to say that master pages and AJAX don't work together in that fashion (seehttp://odetocode.com/Blogs/scott/archive/2007/01/03/9682.aspx).

There are lots of ways to refresh the content inside of the page using AJAX, but what you are trying to do requires the browser to load an entirely new page. :/


Thanks Scott.

I won't be wasting any more time trying to figure that one out.

Guess I am back to using good old Iframe.

Cheers

Dosa.

Updating control in UserControl inside of UpdatePanel

Hello,

I have a page that contains a UserControl. Most of the page (including the UserControl) is wrapped in an UpdatePanel. When an AJAX event on the page occurs, I'd like to call a method inside of the UserControl to update a label. Problem is, when I do this, the page adds a new copy of the UserControl's contents (with the updated label) at the bottom of the page rather than refreshing the existing copy. Any idea what I'm doing wrong?

Thanks.

Are you dynamically creating the controls in the user control or dynamically creating the usercontrol itself? Posting your source code would be helpful.


Nope, no dynamic loading of anything. The page just looks something like this:

<asp:ScriptManagerrunat="server"ID="ScriptManager1"></asp:ScriptManager>

<asp:UpdatePanelID="UpdatePanel1"runat="server">

<ContentTemplate>

<Custom:HotelDetailsrunat="server"ID="HotelDetails1"/>

</ContentTemplate>

</asp:UpdatePanel>

And there's an event in the code-behind of the page:

ProtectedSub DateChanged(ByVal srcAsObject,ByVal eAs Infragistics.WebUI.WebSchedule.WebDateChooser.WebDateChooserEventArgs)

HotelDetails1.UpdateRooms(wdcCheckIn.Value, wdcCheckOut.Value)

EndSub

And in the UserControl, there's a public method like this:

PublicSub UpdateRooms(ByVal StartDateAs DateTime,ByVal EndDateAs DateTime)

litName.Text = StartDate.ToShortDateString()

EndSub


I split the page into two UpdatePanels...one for the even firing controls and one for the UserControls that get updated and that seems to resolve the issue.

Updating controlls outside the UpdatePanel?

Hello,

I need to update a label that is NOT within my updatepanel control..
If I just try to modify it in the codebehind call of my trigger button, nothing happens... makes sense for me because its not included to the panel.

Is there a possibility to manage this?

Thanks in advance,
Andy

If there is some reason why it isn't in the updatepanel, you could put it in its own updatepanel that is set to conditional with a trigger to that button.

Hi Andy,

You can place the label inside an another UpdatePanel and setup the button as the AsyncPostBackTrigger for both UpdatePanels.

Hope this helps,

Updating Controls outside of UpdatePanel on Partial Page Postback

Hi all - I apologize if this has been asked elsewhere. I searched and couldn't find it...

Anyway, I am having an issue where I am doing a partial page postback from a textbox located inside of an UpdatePanel. Based on what the user enters there I need to update a DropDownList located outside of the combo box using the SelectedValue property. When I do it using a normal ASP.NET PostBack without an Ajax UpdatePanel it works fine but when it is called inside of the Handler for the control inside an UpdatePanel it does not work. Is there some setting I need to change to get it to be able to update that control not inside of the UpdatePanel? Thanks for any help.

Don

Hi,

only the controls inside the refreshed UpdatePanel(s) get updated after a partial postback. If you want to update an external control, you should do it using JavaScript on the client side.


HI Garbin, thanks for the post. Actually what I did (and perhaps you were eluding to it) is I placed my DropDownList in its own UpdatePanel with the Update Mode as conditional. Then when my other control fires off and the value of the DropDownList needs to be set, I just set its value and call the Update() method of the UpdatePanel.

Works like a charm.

Thanks!

Don

updating form updatepanel to updatepanel or one to many updatepanel

Hi all,

i have two updatepanels.

<updA>

<uc1 ..ascx> [...Reload this control or updating this panel ]

</updA>

<updB>

<uc2 ..ascx> [...onclick event ]

</updB>

i hope you anyone can solve this..

thanks

pkay

I am not sure what is your question. Can you please clarify? Thanks


When an updatePanel is updated, all the other updatePanels on the page also are updated.

This means that both <updA> and <updB> will be updated if you update one of them.

To avoid this, you can play with the "updateMode" updatePanel's property. This property is set to "always" by default but you can change it to "conditionnal" and then choose by yourself when your update panel has to be updated.


Hope it helps


hi kalahaine,

i got it. thanks for solution.

pkay


No problemSmile

Do not forget to mark your topic as answered.


hi all,

This is an updatepanel updating to other updatepanel: here my correct solution :

--updatepanel one

<asp:UpdatePanelrunat="server"ID="AAAupdatepanel"UpdateMode="Conditional">

<ContentTemplate>

<asp:UpdateProgressID="UpdateProgress2"runat="server"AssociatedUpdatePanelID="AAAupdatepanel">

<ProgressTemplate>

<imgsrc="images/loading-gif-sample-2.gif"alt=""/>

Loading .....

</ProgressTemplate>

</asp:UpdateProgress>

<uc3:AAAControlID="AAAControl1"runat="server"/>

</ContentTemplate>

</asp:UpdatePanel>

--updatepanel two

<asp:UpdatePanelrunat="server"ID="BBBupdatepanel"UpdateMode="Conditional">

<ContentTemplate>

<asp:UpdateProgressID="UpdateProgress2"runat="server"AssociatedUpdatePanelID="BBBupdatepanel">

<ProgressTemplate>

<imgsrc="images/loading-gif-sample-2.gif"alt=""/>

Loading .....

</ProgressTemplate>

</asp:UpdateProgress>

<uc3:BBBControlID="BBBControl1"runat="server"/>

</ContentTemplate>

</asp:UpdatePanel>

--updatepanel three

<asp:UpdatePanelrunat="server"ID="CCCupdatepanel"UpdateMode="Conditional">

<ContentTemplate>

<asp:UpdateProgressID="UpdateProgress2"runat="server"AssociatedUpdatePanelID="CCCupdatepanel">

<ProgressTemplate>

<imgsrc="images/loading-gif-sample-2.gif"alt=""/>

Loading .....

</ProgressTemplate>

</asp:UpdateProgress>

<asp:ButtonID="Button1"runat="server"Text="Button"/>

</ContentTemplate>

</asp:UpdatePanel>

-------here is code behind--------

ProtectedSub Button1_Click1(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles Button1.Click

Me.AAAupdatepanel.Update()

Me.BBBupdatepanel.Update()

EndSub

Updating from a template control

Hello,

I'm having an issue getting a Label inside of an UpdatePanel to change when a button in a GridView PagerTemplate is clicked. I have a label that I am showing the Page X of Y count. I have defined the First, Next, Previous and Last commands as Buttons in the PagerTemplate. The problem is that when I click the button, in the code behind I am setting the Text of the label, but it is not changing on the page. I cannot register the button in the UpdatePanel Triggers, because it is in the PagerTemplate. How can I make the label update from the button?

Thanks,

Nick

If I set up a Trigger on the gridview's databound event, will this cause the label to update?

Thanks,

Nick


You don't need to go that way.

Just do ScriptManager.GetCurrent( this.Page ).RegisterAsyncPostBackControl( control );

You have to do this on each post though. (ItemCreated will get fired each post)


Would this be done in the Pages Load event, or the button's click event?

Thanks,

Nick


Subscribe to the ItemCreated event in your grid and do it on all the rows. (e.Item).

Updating GridView ,

Hi All,

I am having a problem in updating my GridView partially (AJAX). Here is my scenario.
I have 2 UpdatePanel. (DisplayUpdatePanel and EditUpdatePanel)

Inside "DisplayUpdatePanel" i have 1 GridView which shows my data from my database. i'm using XML schema DataSet and ObjectDataSource to bound data to my gridview
SelectMethod runs perfectly.

Inside "EditUpdatePanel" i have some textboxes, and links buttons (Update,Delete,New) and one HTML Editor.

The way it works as follow:

1. If one row is selected in "DisplayUpdatePanel" then My "EditUpdatePanel" will get updated with the same values from "DisplayUpdatePanel" automatically.

2. Inside my "EditUpdatePanel", i can edit all the values.

3. Once i finished, i can click "Update" link button to execute my Update Stored procedure. which i Typed it manually instead of being autogenerated by the wizard.

Update Stored Procedure runs perfectly as i expected.

My problem here is that my "DisplayUpdatePanel" doesnt update automatically once the data has been updated.

anyone know how to solve my problem?


below are my triggers from both UpdatePanel.

"DisplayUpdatePanel"

<Triggers>
<asp:AsyncPostBackTrigger ControlID="LNK_UPDATE" EventName="DataBinding" />
</Triggers>

"EditUpdatePanel"

<Triggers>
<asp:AsyncPostBackTrigger ControlID="DisplayUpdatePanel" EventName="SelectedIndexChanged" />
</Triggers>

Thank You Very Much

On3

<Triggers>
<asp:AsyncPostBackTrigger ControlID="LNK_UPDATE" EventName="Click" />
</Triggers>


Thank yourmaiya for your reply.

I've tried your solution, but still not my gridview is still the same. it doesn't update by itself ...
is there any relation with my multiview?

because i put all my update panels inside one of the views.
thanks



Once you update GridView in server with your StoredProcedure then call DisplayUpdatePanel.Update();


Assuming that you have done what was previously suggested, that is, ensure the UpdatePanel's children are rendered via invoking the Update() method. I also found that disabling view state on the GridView solves some issues with the GV updating after an asyn postback. Hope this helps.


Hi Amit, thank you for your reply :)

my DisplayUpdatePanel still doesnt update its content by itself...
What do you mean by "Update GridView in Server" ... because, as far as i understand,
my scenario is actually updating the database directly through my StoredProcedure.

below is my snippet for updating my data.

protected void UpdateArticle()
{
MyConn = new Connection();
DateTime CurrDate = DateTime.Now; // Get the Current Date and Time.
SqlCommand SqlCmd = new SqlCommand("Article_Update", MyConn.GetConnection());
SqlCmd.CommandType = CommandType.StoredProcedure;

Label ArticleID = (Label) GridView3.SelectedRow.FindControl("Label2");

SqlCmd.Parameters.AddWithValue("@.Title", TXT_ArticleTitle.Text);
SqlCmd.Parameters.AddWithValue("@.Cat_Id", Convert.ToInt32(DRP_FileUnder.SelectedItem.Text));
SqlCmd.Parameters.AddWithValue("@.Content", FCKeditor.Value);
SqlCmd.Parameters.AddWithValue("@.Summary", TXT_Summary.Text);
SqlCmd.Parameters.AddWithValue("@.Original_ArticleID", Convert.ToInt32(ArticleID.Text));

if (MyConn.isConnected() == false)
MyConn.Connect();

SqlCmd.ExecuteNonQuery();
MyConn.CloseConnection();

}

is there any more clues for my case ?

thank you Amit



on3_cool:

protected void UpdateArticle()
{
MyConn = new Connection();
DateTime CurrDate = DateTime.Now; // Get the Current Date and Time.
SqlCommand SqlCmd = new SqlCommand("Article_Update", MyConn.GetConnection());
SqlCmd.CommandType = CommandType.StoredProcedure;

Label ArticleID = (Label) GridView3.SelectedRow.FindControl("Label2");

SqlCmd.Parameters.AddWithValue("@.Title", TXT_ArticleTitle.Text);
SqlCmd.Parameters.AddWithValue("@.Cat_Id", Convert.ToInt32(DRP_FileUnder.SelectedItem.Text));
SqlCmd.Parameters.AddWithValue("@.Content", FCKeditor.Value);
SqlCmd.Parameters.AddWithValue("@.Summary", TXT_Summary.Text);
SqlCmd.Parameters.AddWithValue("@.Original_ArticleID", Convert.ToInt32(ArticleID.Text));

if (MyConn.isConnected() == false)
MyConn.Connect();

SqlCmd.ExecuteNonQuery();
MyConn.CloseConnection();

DisplayUpdatePanel.Update();

}


Hi AMit,

i still cannot use the "DisplayUpdatePanel.Update()" for my case.
however, i found the solution by my self.
here is what i have done.
1. Instead of executing my UpdateStored Procedure directly as the link button click, i attached my stored procedure into my ObjectDataSet.
2. Then i set the default value of each my "UpdateParameters" in ObjecDataSource onto the appropriate controlId.Text
3. In My protected void LNK_UPDATE_Click(object sender, EventArgs e) , i just call my function which executes the ObjectDataSource update command.

The snippet as follows.

protected void LNK_UPDATE_Click(object sender, EventArgs e)
{
UpdateArticle(); // Execute UpdateCommand.
ClearALLValues(); // Clear All values in the forms.
SetButtonsIn_EditPanel(false, false); // Set Appropriate buttons.
}

protected void UpdateArticle()
{
try
{
Admin_ArticlesODS.Update();
}
catch (System.Reflection.TargetInvocationException error)
{
FCKeditor.Value = error.ToString(); // Display error catch by the TargetIncovationExection to the editor
}

}

Hopefully It helps.