Showing posts with label update. Show all posts
Showing posts with label update. Show all posts

Wednesday, March 28, 2012

UpdateProgress not showing.

I have an update panel that has 4 triggers to update it, and then I have an UpdateProgress that shows for that panel.


However the progress doesn't show unless a button in the panel is clicked, can it be made to show whenever the panel updates?


Thanks.

The UpdateProgress will not show automatically for any asyncpostback trigger. you have to manually show it. Check out this urlhttp://www.asp.net/AJAX/Documentation/Live/tutorials/ProgrammingUpdateProgress.aspx -Displaying Update Progress Using Client Script section.


Thanks! Will check into this.

Yes you have to see the online documentation

http://asp.net/ajax/documentation/live/tutorials/ProgrammingUpdateProgress.aspx

Updateprogress problem

I am new to AJAX. And I don't understand why this doesn't update the label. The problem started on another page with Placeholders that don't get updated if I use UpdatePanels.

Thanks Asger

<%@dotnet.itags.org.PageLanguage="VB" %>

<%@dotnet.itags.org.RegisterAssembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"Namespace="System.Web.UI"TagPrefix="asp" %>

<%@dotnet.itags.org.RegisterAssembly="AjaxControlToolkit"Namespace="AjaxControlToolkit"TagPrefix="ajaxToolkit" %>

<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<scriptrunat="server">

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

lbl1.Text = tbCity.Text

EndSub

</script>

<htmlxmlns="http://www.w3.org/1999/xhtml">

<headrunat="server">

<title>Untitled Page</title>

</head>

<body>

<formid="form1"runat="server">

<div>

<asp:ScriptManagerID="ScriptManager1"runat="server">

</asp:ScriptManager>

<asp:UpdateProgressID="UpdateProgress1"runat="server">

<ProgressTemplate>

<div>

<asp:ImageID="Image1"runat="server"ImageUrl="~/images/vent.gif"ImageAlign="Top"/>

</div>

</ProgressTemplate>

</asp:UpdateProgress>

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

<ContentTemplate>

<asp:TextBoxID="tbCity"runat="server"AutoCompleteType="None"autocomplete="off"Width="200px"AutoPostBack="true"OnTextChanged="tbCity_TextChanged"/><br/>

</ContentTemplate>

</asp:UpdatePanel>

<asp:Labelrunat="server"ID="lbl1"/>

</div>

</form>

</body>

</html>

AsgerJornow:

I am new to AJAX. And I don't understand why this doesn't update the label. The problem started on another page with Placeholders that don't get updated if I use UpdatePanels.

Hi asger,

Your setup is wrong!

The label doesn't get updated because it is NOT on this updatepanel!!!!

Your textbox should be outside the updatepanel, the label inside, then define the textbox as a trigger of the updatepanel.

Or just place them both on the updatepanel.

Kind regards,
Wim


Thank you, now I get the picture. And it seems to be working.

Kind regards
Asger J?rnow

UpdateProgress Problem

I'd like to show the update progress template in the center of div, which content is updated with update panel. I tried to do it with z-index.. but it works only with absolute positioning so it can be centered only in the whole browser window. What should i do to make it work in the right way? =)

Here is a simple illustration of the feature i need

*****************Update Panel*************
* *

* *

* Loading... *

* *

* *

**********************************************


I have anarticle on creating a modal UpdateProgress. It uses absolute positioning, but you can use relative positioning to position the message within your container. There is ademo available as well... you can use Firebug to mess around a bit with the styles in real-time (just disable the visible=hidden style on the UpdateProgress' main DIV).

Hope this helps.

-Damien


Everything work nice when we use absolute positioning.. but with realtive positioning z-index doesn't work so i failed to put it to foreground.

According tohttp://msdn2.microsoft.com/en-us/library/ms533005.aspx

It is quite possible that relatively positioned elements will overlap with other objects and elements on the page. As with absolute positioning, you can use the z-index attribute to set thez-index of the positioned element relative to other elements that might occupy the same area. By default, a positioned element always has a higher z-coordinate than its parent element so that it will always be on top of its parent element.

I also messed around with the styles on the sample I sent you using FireBug and verified that I was able to set the z-index on a relative positioned element. For example:

#processMessage {

background-color:#FFFFFF;

border:1px solid #000000;

left:43%;

padding:10px;

position:relative;

top:-300px;

width:14%;

z-index:1001;

}

-Damien


You are looking like this one

http://mattberseth.com/blog/2007/06/aspnet_ajax_canceling_an_async_1.html


Thx! Look like it's what i need =)

UpdateProgress stops working

Hello everybody,

my problem: I have a gridview in an update panel, and the gridviews header contains some DropDownLists for filtering data. Also the Gridview is enabled for Sorting

and Paging. All works fine. But to inform the user that the action he started is on the way, i included a UpdateProgress with a gif animation. So when the user starts filtering

or sorting the gif animation is shown and animated. But after a short time, it stands still. A second or two later, the GridView is bound completely and the gif disappears.

So something seems to block the UpdateProgress. What am i doing wrong ? the gif animation is on top of the gridview.

any hint is aprreciated, thanks a lot !

This happens when the browser is rendering the response... Haven't found really anything to do about it :(

-Damien

UpdateProgress Renders Differently in IE7

I am using an update progress control which contains an animated gif and then some text below. The style on the DIV creates a box around it. It renders fine in IE6 but IE7 the Please Wait...shows up outside the box...any suggestions? Here is the code and css style:

<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
<Div class="wdeProgressIndicator">
<img src="http://pics.10026.com/?src=images/progressbar.gif" alt="Please Wait..." />
Please Wait...
</Div>
</ProgressTemplate>
</asp:UpdateProgress>

background-color: #ffffff;
margin: auto;
height: 10px;
width: 300px;
position: absolute;
left: 50%;
top: 40%;
margin-left: -150px;
margin-top: -5px;
border-right: #5d7b9d thin solid;
border-top: #5d7b9d thin solid;
border-left: #5d7b9d thin solid;
border-bottom: #5d7b9d thin solid;
padding-right: 5px;
padding-left: 5px;
padding-bottom: 5px;
padding-top: 10px;

If i do the following it works fine, so there has to be more html in the page, that is manipulating something. In any case, why not make the image a background-image on the div with the css, and rmeove the image tag all together, so the image is just part of the div anyway.

<html>
<style>
.wdeProgressIndicator{
background-color: #ffffff;
margin: auto;
height: 10px;
width: 300px;
position: absolute;
left: 50%;
top: 40%;
margin-left: -150px;
margin-top: -5px;
border-right: #5d7b9d thin solid;
border-top: #5d7b9d thin solid;
border-left: #5d7b9d thin solid;
border-bottom: #5d7b9d thin solid;
padding-right: 5px;
padding-left: 5px;
padding-bottom: 5px;
padding-top: 10px;
}
</style>

<body>
<Div class="wdeProgressIndicator">
<img src="http://pics.10026.com/?src=images/progressbar.gif" alt="Please Wait..." />
Please Wait...
</Div>
</body>
</html>


Good suggestion..thanks. That seems to work for now.

UpdateProgress Triggers

Hey gang.

I have a XmlDataSource (RSS Feed) bound to a DataList and I am curious how on initial load up I can display the update progress when the page is loaded?

I tried to do the following:

<Triggers> <atlas:ControlEventTrigger ControlID="XmlDataSource1" EventName="Transforming" /></Triggers>

I am really not sure how to tackle this. I know that the update progress occurs on executing server side code, but not sure how to attach it to data binding changes etc.

Thanks and take care!

hello.

well the updateprogess is a simple control that shows its content during a partial postback which might occur due to an updatepanel refresh. what you're trying to do (show progress while the processing is being done on the server side) can only be done during the initial page load or a complete postback (not during a partial postback!). there are several options that you can follow for that progress info during the rendering of the page ( I do believe thatwww.codeproject.com has several articles about it).


Thanks for your help!

How does Live.com show the RSS feed loading progress animation then when it is loading the feeds during the initial page load?

Thanks and take care.


hello.

well, i haven't used live.com for a while now. however, i'd say that what it does is show that info when it starts getting the info and then it removes it when it's finished. this is easilly achieved when you're using a web service to get the info (since it'll be donw asynchronously). btw, this is what happens when the panels postback. however, i do think that you only get the info that something is loading and don't get anything about the percentage of the operation being performed (which i assumed you needed in the previous post).

updates from another thread

Hi, I'm trying to get a label control to update with dynamic information when a timer does its tick event.

I can get it to update with information hard-coded into the tick event, but i can't seem to get any data from a global variable or other shared resource.

Here's what i have so far-

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;using System.Threading;public partialclass _Default : System.Web.UI.Page {string temp;protected void Page_Load(object sender, EventArgs e) { }protected void Timer1_Tick(object sender, EventArgs e) { Label1.Text ="Tick at " + DateTime.Now.ToString()+"<br />";if (temp !=null) Label1.Text +="register at-"+temp; }protected void Button1_Click(object sender, EventArgs e) { Thread a =new Thread(Foo); a.Start(); }protected void Foo() {while (true) { Thread.Sleep(100); temp = DateTime.Now.Day.ToString(); } }}

(that's actually a +"<br />" at the end of the first line on the tick event)

and the markup-

<%@dotnet.itags.org. Page Language="C#" 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" runat="server" /> <div> <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" /> </Triggers> </asp:UpdatePanel> </div> <asp:Timer ID="Timer1" runat="server" Interval="500" OnTick="Timer1_Tick"> </asp:Timer> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /> </form> </body></html>
the 'register at" text never fires. I've tried using Session and Cache variables in place of a global string but no luck.

I am not sure how it is not working when puting it in Session/Cache, would you mind posting the code?


Here's the code using session-

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;using System.Threading;public partialclass _Default : System.Web.UI.Page {protected void Page_Load(object sender, EventArgs e) {if (!IsPostBack) Session["Store"] =null; }protected void Timer1_Tick(object sender, EventArgs e) { Label1.Text ="Tick at " + DateTime.Now.ToString()+"<br />";if (Session["Store"] !=null) Label1.Text +="register at-" + Session["Store"].ToString(); }protected void Button1_Click(object sender, EventArgs e) { Thread a =new Thread(Foo); a.Start(); }protected void Foo() {while (true) { Thread.Sleep(100); Session["Store"] = DateTime.Now.ToString(); } }}

It is not possible to access the session/request/response/cache from an different thread, also creating thread/using threadpool is not an good practise.


How should I update the label control then?

Or if using another thread is not good practice, i don't see how i'm going to be able to get the button postback to finish so i can update the label cleint side from the server during a (partial) postback


I am still not clear about your requirment, anyway here is the code snippet which will allow you to access the session from a different thread:

protected void Button1_Click(object sender, EventArgs e){ ThreadPool.QueueUserWorkItem(new WaitCallback(foo), Session);}private void foo(object state){ HttpSessionState session = (HttpSessionState)state; session["Store"] = DateTime.Now.ToString();}

Initial tests with this method provide the functionality I was after. I'll try to implament it today and let you know how it goes.


Indeed this seems to work well. I have 2 follow up questions relating to it though-

1. I went ahead and passed the session variable to other functions I use by reference...I'm guessing this is ok?

eg-

protected void Button1_Click(object sender, EventArgs e) { ThreadPool.QueueUserWorkItem(new WaitCallback(foo), Session); }private void foo(object state) { HttpSessionState session = (HttpSessionState)state; Thread.Sleep(100); session["Store"] = DateTime.Now.ToString(); Thread.Sleep(1000); foo2(ref session); }private void foo2(ref HttpSessionState session) { session["Store"] = DateTime.Now.ToString(); }

2. I notcied the application context still stays around after the browser is closed(presumably waiting for the thread to end?) should I manually be stopping the proccess somehow?


1. Yes you can pass it from the worker thread method.
2. The Thread returns to threadpool as soon as the foo2 method completes, no do not have to do anything.

Since it solved your problem, dont forget to mark it as answer.


Let's take another stab at this. You didn't really state the object of what you were trying to achieve. Why are you trying to use the variable temp? And if it truly is a shared variable, why didn't you just make it static? A Session variable certainly isn't global to the application. There's got to be a reason you're doing this and perhaps there is a much better approach.


The end result alows me to provided feekback to the cleint about a job currently being ran on the server (in psudo-real time). The timer updates the label on the client but it needs to be able to read from a variable (or somthing) that the job running on the server can write to. The session variable only needs to be global to the session (mutliple people could be using this at a time).

If there is another way to do this without using the cache or session I'd prefer too, but I havn't seen a way to do this yet...


Well there are certainly more expensive techniques such as using a Windows Service to host the job and querying it. Or using a DB entry to write the job status and querying it with a web service.

However you might be interested in this person's approach. He used a Cache object, but there is no reason it couldn't be Session (but Cache can be used if a unique identifier is set for a collection of jobs). The main difference is that his whole task is in this object, and it's public properties can be used to get it's status.

http://www.eggheadcafe.com/articles/20051223.asp


Use the Cache/ Store the Jobs status in DB as muliple user will be able to see the same result. BTW for one User you cannot use the session for storing the long running task status as the session access is always sequential.


I did try using the cache and i wasn't abe to get it to work ( see the first post). Essesntially the source looks the same as the session example except you use cache['whatever'] instead of session["whatever"].

I was under the impression that the session[] object was unique for each 'cleint session' that is, each cleint request would have it's own session object to work with. If this is the case why can't i use it for multiple users

@.wrayx1- I wanted to stay away from using a service althogh I have read some thing about how to get them to work, i think it overcompliactes the simple job I'm trying to do.

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.

Monday, March 26, 2012

Updating a website with data from an asynchronously called Webservice

Hi!

I wrote the following code to update a label on my aspx-page with data retrieved by an asynchronously called Webservice.

Protected Sub Page_Load(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles Me.LoadIf Not Page.IsPostBackThen Dim wsAs localhost.WebServiceTest =New localhost.WebServiceTestDim ResultAs IAsyncResult = ws.Beginmessages(AddressOf renderResult, ws)End If End Sub Private Sub renderResult(ByVal ResultAs IAsyncResult)Dim wsAs localhost.WebServiceTest =CType(Result.AsyncState, localhost.WebServiceTest) Label1.Text = ws.Endmessages(Result)End Sub

The problem is that the Label (which is surrounded by an Updatepanel) does not get updated with the value returned by the Webservice although "renderResult" is executed correctly. (Maybe the problem is that the asynchronous function is called in a different thread on the webserver?)

Do you have any ideas or solutions to solve this issue?

Thank you

No suggestions?


Try doing your asynchronous webservice calls from the client-side rather than from the server.

http://www.asp.net/learn/ajax-videos/video-79.aspx

http://www.asp.net/AJAX/Documentation/Live/tutorials/ASPNETAJAXWebServicesTutorials.aspx


As DisturbedBuddha points out, you would probably want to do this sort of thing client side (remember the runat=server thing).

But, if youreally want to do this server side, my first question would be - is the updatepanel inside a form?

Cheers

Martin


Thank you for your help.

Calling the webservice client-side worked!

Updating an Application to the April CTP

Hello,

I am trying to update a web application to use the April CTP. I have refreshed the the Atlas .dll, but the application still seems to be referencing the March version. Any new application works fine when using from the Visual Studio Atlas Template based on the updates provided by the April CTP.

Is there a Manual way to make sure that I am using the newer version on an application that was started using the March version?Normally, you can't use March CTP and April CTP together. You have to uninstall the March CTP before installing the April CTP. From then, you applications written with the March CTP will now work with the April CTP.

Hope this helps
It's possible that your browser is caching the old Javascript includes I suppose - have you tried clearing your cache? Or setting debug=true?

Otherwise, if you've copied the microsoft.atlas dll into the bin directory of your app, I can't see what might be causing the problem.

Thanks,
Carlos

hello.

copying the new dll should solve the problem you're having. why do you say your app is using the march version?


Hi Luis,

It's not our app...it's the files that get installed. We are just now adding Atlas to our application. When the installer runs, it puts the zip files for the Atlas project into the Project Templates folder defined in VS 2005, and installs some stuff into C:\Program Files\<see previous post>. Those files, from what I can gather, is what is used for a new Atlas project.

When I create a new Atlas project after installing the April CTP, the Microsoft.Web.Atlas.dll has a file version of 2.0.50727.60309, dated 3/17/06, and the readme.txt that pops up has the same date in it. Unless I'm missing something, this is the March CTP.

All I'm doing is trying to install the April CTP and create a new app from it. I uninstalled the project templates from the location specified by the VS 2005 setting before running it, and it still put the March CTP files into that location. I'd suspect that it's providing a cached version of the project when it creates the new one, but even the files in Program Files are old.

Thanks,
John


Hey All -

It must have been some wierd caching either within our network or in the browser. I dusted off Mozilla to try downloading it; the first click downloaded the Mart CTP again. But downloading through the direct 'If your download doesn't start...' link got the correct one.

Very strange.

Thanks,
John

hello again.

well, yes, the files placed on the program files\microsoft asp.net\atlas are everything you need to deploy your app.

and yes, it looks like you have the wrong version. mine says:2.0.50727.60406


I guess I should have clarified... it seems to be using the "March CTP" based on the errors that still existed. After the removal of the March CTP and Installation of the April, all hot fixes work fine... except in an application that was created using the March CTP. That one does not want to update.

Thanks for you replies!


hello.

updating that app should be as easy as dropping the new dll on the bind folder. have you checked the version of the dll on the bin folder? according to your previous post, it seems like you're still using the olde version...

Updating an Update Panel on a page from Javascript

Hi All,

I am trying to update an update panel in a webform from Javascript. Form the documentation I think this might be possible using the Sys.Webforms.PageRequestManager but I have not been able to achieve this so far.

Any help would be greatful.

Hamlet

Hi Hamlet !

I been having the same wish ! After a lot of googeling the only way I found is to put an invisible button in a updatepanel and then raise it's postbackevent by registrering it's postbackevent in the scripthandler. Using the

$get('<%= YourControl.ClientID %>').click();

didn't work in FireFox and I supspect - but don't know for sure - not in ie7 ! One thing I wasted alot of time on was that the ValidateEventError but that was because I supplied an argument when registrering the clientscript in the scripthandler !

This feels like an uggly hack to accomplish what we want - but I didn't find any other way !

/MC24


I have been using

javascript:__doPostBack('__Page', 'some data' ) from the client.

This worked fine in the earlier release, but Beta 2.0 broke it because it started doing full postbacks instead of partial ones.

Evan


You can use the extender control I build.

http://daron.yondem.com

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 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 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 Atlas

I must update my Atlas version.
I was develop some projects with April CTP.
How I do now? Which is the correctly procedure?
I must install the new version that overwrite the previus one? or I must uninstall the previus release?
...and what about updating existing project?
is it automatic or I must manually update? (changing the dll in bin directory??)
thanx

Hi,

if you installed the previous version via the .msi installer, then you should uninstall the previous release.

Regarding your projects, you have to change the dll referenced in the bin directory.

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 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 Database using AJAX.

Hello Experts,

How can i update the database from client side after removing the focus
from the particular panel.

You'll need to use a bit of client-side scripting. You can attach an onblur event handler to the panel element, and use script to fire off the postback. One of the easiest ways to do that is to use a hidden button inside of the panel, and call button.onclick() from you onblur handler.

on blur event of textbox u have to attach the ClientScript.RegisterClientScriptBlock()

so it will perform operation that is available in the script.

Updating Gridviews

I need to update a gridview with another gridview, but I can't figure out how to do it.

I've got the AJAX component installed and it looks easy, but I can't find the right combination to make it happen.

I want the 1st control to look like this on the page...

item1

item2

item3

then when I choose one of them, I want it to update the gridview beside it.

Right now, I'm playing with the selected properties, but don't seem to have much luck.

Can anybody help me with this? it works just fine with other controls, but not with the gridview. And I know there's just something simple I'm missing.

thx.

Hello,

I would suggest using nested update panel controls. Put the second grid in one update panel, and then put both grids in new update panel. Then just put the event on wich you want the second gridView to update to the triggers collection. Example athttp://www.asp.net/AJAX/Documentation/Live/overview/UpdatePanelOverview.aspx section "Using nested UpdatePanel controls".

Updating Issue: when Im trying to update from 1.0.60504.0 to 1.0.60731.0

Hi guys,

I'm developing a site (which is still Local and not uploaded yet) that uses Atlas technology.

Everything was good since I just tried to update Atlas Toolkit and Atlas Toolkit Extender to add some extra feature like rating and etc.

I got "Object reference not set to an instance of an object." !

firstly I thought it's because of my settings but I search and found that there is no problem in that matter, when I replaced new ones (Microsoft.AtlasControlExtender.dll, and AtlasControlToolkit.dll) with older ones, the problem resolved.

But I can't use new features on my site!SadConfused

Can anybody help please?!

Just a thought, but have you replaced Microsoft.Web.Atlas.dll as well? (you will need to if you are updating the toolkit)

Well, I did it, but when I saw your message I make it double check and for more accuracy I copy all DLL's related to Atlas from Atlas toolkit's sample website's bin folder, the problem still exisis!

Here is the stack trace for the error it may helps:

[NullReferenceException: Object reference not set to an instance of an object.]
Microsoft.AtlasControlExtender.ExtenderControlBase`2.ConnectDataBindingHandlers() +241
Microsoft.AtlasControlExtender.ExtenderControlBase`2.OnInit(EventArgs e) +31
System.Web.UI.Control.InitRecursive(Control namingContainer) +345
System.Web.UI.Control.InitRecursive(Control namingContainer) +196
System.Web.UI.Control.InitRecursive(Control namingContainer) +196
System.Web.UI.Control.InitRecursive(Control namingContainer) +196
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1795


That's helpful - thanks.

You'll get this exception if the extender can't find one of the target controls (e.g. the value in TargetControlID). I've made a code change to help with debugging this, but double-check to make sure that each of those targets is correct.

You can also try handling the OnResolveClientID event that the extender will raise when it can't find a target as well to work around this.


I double-checked those but everything seems to be just fine!

Plus with no change in codes and just with replacing new DLLs with older ones this problem arose!

I'm just confused! I change all references through the refernces page and I think everything must be in its place, but still I stuck!

and the Debugger won't help me anymore! and this stack trace is the only thing I have!

Please Help!


Did you try handling OnResolveClientID?
I wonder if your situation is anything like http://forums.asp.net/thread/1366243.aspx ?

Yes it's the same code - but we're still not sure how folks are getting into that state.


Well, I havre to say "I'm not sure!"

you know, because Atlas is a new technology and I'm new to it too, when I want to add some feature to my site, FIrst I try to check it in a Test project to be sure, but situation is really different now!

because I have lots of Atlas extender's controls on my pages (specially in my Master page) and they are all good until I update DLL's, it's even harder to understand.

and for you last question, Yes I handled that handler but still same Error, I don't know but I think this error would happen even sooner than that you may think in its life time so this handler wont be any help.


Could you (or someone) paste in code that causes this? The fix we have didn't address the problem, so we're not sure what the exact scenario is. If you have the ASPX that causes it, that would be very helpful.

well,

I can't paste codes here (as they are more than 20 ASPX pages)!

but if I could it would not be hepful because we can't find the source of error and Stack trace is no help for ASPX pages I think.

but, let me tell you the scenarion one more time,

I just started to develope an Atlas Based web site but it takes such long time that I can now use July CTP Atlas Toolkit Control too!, but I have been using previous version of toolkit before, and this site contains some features like autoupdate panels, collapsible panels, alwaysvisible controls and all of them works well with previous version of Toolkit but as I got july CTP, and I found Ratings really helpful, I decided to use it, when I tried to add rating (which surely tries to update related DLLs such as Atlastoolkit, and web.atlas and atlas extenders) it just stuck! and this Null refernce error message became to be a constant part! (consider that the site uses some features specially Alwaysvisible toolkit extender in Master page that all of my pages derived from)

first I thought there is some code related error, but as I revert the DLLs the error disappeared!

That's it. thanks for you participation, but is there somebody to help?


For some horrible crossposting, just to make sure you're aware: http://forums.asp.net/2/1367145/ShowThread.aspx#1367145 .


Sweet, that was the bit of context I needed. I've got the exception reproing now...I'll see what the story is.

Thanks!


yes I know and I visited your Thread too, but I got none helpful yet. thanks for making me informed

Everyone -

I believe I've got a fix for this issue (thanks torchern13 for helping pull the pieces together).

If you're running into this issue, please pick up changelist 2820 (or later), build it, and post back here if it does not.

http://www.codeplex.com/SourceControl/ListDownloadableCommits.aspx?ProjectName=AtlasControlToolkit

Thanks,

Shawn