Showing posts with label control. Show all posts
Showing posts with label control. Show all posts

Wednesday, March 28, 2012

AJAX UpdateProgress

hi

i working with AJAX recently i am facing one problem in UpdateProgress control.It work fine display the message and animation picture perfect.My problem is i want pass a Value to updateprogress control in Example now it give me

Updating databases ..... and some animation.

i want

Updating Databases Employee Name : XXXXXXXXXXXXXXXXXXXX & animation.

How to pass these value in label control in updateprogress control ?

Q2) in UpdateProgress Run how to disable other control execpt the cancel button in updateprogress control ? Or a popup dialog box display on middle of page and disbaled the main web page unless u cancel the control ?

Q3) AJAX control work with microsoft product with out any problem.when i try with component art products it give me error Sys.event.Ui.Dom what could be reason.

Q3)

For Question 1, seehttp://forums.asp.net/t/1152621.aspx

Question 2, you can use a Modal Popup approach. Example here:http://www.visoftinc.com/samples/UpdateProgress.aspx and how to do this, here:http://blogs.visoftinc.com/archive/2007/09/10/modalupateprogress.aspx

Question 3, not to familar with Component Art; you may want to check over in their forums...

-Damien

AJAX UpdatePanel, ASP.NET Repeater Control, and custom JavaScript for postback - Single ro

Good afternoon, everyone.

I am running into an interesting problem with the AJAX UpdatePanel and the ASP.NET Repeater control. For some background, we have been asked to develop a dynamic single row update for a data table that needs to be maintained by the users. The analyst does not want to use buttons, as this is supposed to be a data entry style of application (hands on keyboard at all times, no mouse interaction). The following rules define the behavior the analyst wants to have happen:

When a user changes the data in a row, the row should be marked as changed but not saved yet. (No individual control saves to the database.)

When a user leaves a row that has been changed, that row should be posted back to the server and saved to the database.

I was able to get this partly working with a GridView inside of an UpdatePanel, by using some custom client-side JavaScript to detect changes and to determine when to call __doPostBack to force the save to the database.

However, the entire GridView is posting back each time, which is not the desired effect. The analyst wants each row to post back individually. We are also running into enough of a performance bottleneck with the GridView postback, that we decided to try using Repeater instead, with an UpdatePanel around each row of data.

Unfortunately, changing the GridView to a Repeater turned out to be problematic. I am running into the following issues:

When the custom __doPostBack JavaScript method is called by a control inside a Repeater, which is nested inside an UpdatePanel, the entire page is posting back instead of just the UpdatePanel.

When attempting to move the JavaScript from the .aspx page to a JavaScript .js file, the client-side JavaScript aborts with an "Object expected" error when the custom __doPostBack JavaScript method is called. (The same code works fine when embedded in the .aspx page.)

I have managed to prune down the code to the bare essentials, and I was able to replicate these problems with standard ASP.NET code.

Would some of you please look over the code below and let me know if there is something obvious that I am doing wrong? Or would someone please explain why this is working fine for GridView but not for Repeater?

Thanks in advance for any help that you can provide.

We also have a suggestion to convert the custom JavaScript to server-side code by building custom controls that would expose OnFocus as a server-side event. Have any of you done something like this before? If so, do those custom controls work with the AJAX UpdatePanel?

Jeff Parker
Senior Software Developer
Explore Information Services


default.aspx - UpdatePanel contains Repeater control, client-side JavaScript embedded in the aspx page

-- default.aspx

<%@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> This is some text sitting outside the main control. It should not be refreshed by AJAX.<%=DateTime.Now%><br /> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" /> <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="conditional"> <ContentTemplate> <script type="text/javascript"> var currentRowChanged = -1; function SetRowChanged(rowIndex) { currentRowChanged = rowIndex; } function CheckRowChanged(repeaterUniqueID, controlID, newRowIndex) { if((currentRowChanged != -1) && (currentRowChanged != newRowIndex)) { saveInfo = 'SaveData$' + controlID + '$' + currentRowChanged + '$' + newRowIndex; currentRowChanged = -1; __doPostBack(repeaterUniqueID, saveInfo); } } </script> <asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="Repeater1_ItemDataBound" > <HeaderTemplate> This is inside the update panel and should be updated.<%=DateTime.Now%><br /> </HeaderTemplate> <ItemTemplate> <asp:TextBox ID="TextBox1" runat="server" />  <asp:TextBox ID="TextBox2" runat="server" />  <asp:TextBox ID="TextBox3" runat="server" /><br /> </ItemTemplate> </asp:Repeater> </ContentTemplate> </asp:UpdatePanel> </form></body></html>

-- default.aspx.cs

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) {if(!IsPostBack) { BindData(); }else {if (Request.Form["__EVENTTARGET"].Contains(Repeater1.UniqueID.Replace(':','$'))) {if (Request.Form["__EVENTARGUMENT"].Contains("SaveData$")) {string[] aszSaveParameters = Request.Form["__EVENTARGUMENT"].Split('$');string szCurrentControlID = aszSaveParameters[1];int iSaveItemIndex = Convert.ToInt32(aszSaveParameters[2]);int iCurrentRowIndex = Convert.ToInt32(aszSaveParameters[3]); RandomizeRow(iSaveItemIndex); ScriptManager1.SetFocus(szCurrentControlID); } } } }private void RandomizeRow(int index) { RepeaterItem riSaveRow = Repeater1.Items[index]; Random oRandom =new Random(); TextBox TextBox1 = (TextBox)riSaveRow.FindControl("TextBox1"); TextBox1.Text = Convert.ToString(oRandom.Next()); TextBox TextBox2 = (TextBox)riSaveRow.FindControl("TextBox2"); TextBox2.Text = Convert.ToString(oRandom.Next()); TextBox TextBox3 = (TextBox)riSaveRow.FindControl("TextBox3"); TextBox3.Text = Convert.ToString(oRandom.Next()); }private void BindData() { Repeater1.DataSource = GetSampleData(); Repeater1.DataBind(); }private DataTable GetSampleData() { DataTable dtbSampleData =new DataTable(); dtbSampleData.Columns.Add("TestColumn1",typeof(string)); dtbSampleData.Columns.Add("TestColumn2",typeof(string)); dtbSampleData.Columns.Add("TestColumn3",typeof(string)); DataRow drSampleData = dtbSampleData.NewRow(); drSampleData["TestColumn1"] ="column 1, row 1"; drSampleData["TestColumn2"] ="column 2, row 1"; drSampleData["TestColumn3"] ="column 3, row 1"; dtbSampleData.Rows.Add(drSampleData); drSampleData = dtbSampleData.NewRow(); drSampleData["TestColumn1"] ="column 1, row 2"; drSampleData["TestColumn2"] ="column 2, row 2"; drSampleData["TestColumn3"] ="column 3, row 2"; dtbSampleData.Rows.Add(drSampleData); drSampleData = dtbSampleData.NewRow(); drSampleData["TestColumn1"] ="column 1, row 3"; drSampleData["TestColumn2"] ="column 2, row 3"; drSampleData["TestColumn3"] ="column 3, row 3"; dtbSampleData.Rows.Add(drSampleData); drSampleData = dtbSampleData.NewRow(); drSampleData["TestColumn1"] ="column 1, row 4"; drSampleData["TestColumn2"] ="column 2, row 4"; drSampleData["TestColumn3"] ="column 3, row 4"; dtbSampleData.Rows.Add(drSampleData); drSampleData = dtbSampleData.NewRow(); drSampleData["TestColumn1"] ="column 1, row 5"; drSampleData["TestColumn2"] ="column 2, row 5"; drSampleData["TestColumn3"] ="column 3, row 5"; dtbSampleData.Rows.Add(drSampleData); dtbSampleData.AcceptChanges();return dtbSampleData; }protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e) {if((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem)) { DataRowView drvSampleData = (DataRowView) e.Item.DataItem; TextBox TextBox1 = (TextBox)e.Item.FindControl("TextBox1"); TextBox1.Text = Convert.ToString(drvSampleData["TestColumn1"]); TextBox1.Attributes["onchange"] ="javascript:SetRowChanged(" + e.Item.ItemIndex +")"; TextBox1.Attributes["onfocus"] ="javascript:CheckRowChanged('" + Repeater1.UniqueID +"', '" + TextBox1.ClientID +"', " + e.Item.ItemIndex +")"; TextBox TextBox2 = (TextBox)e.Item.FindControl("TextBox2"); TextBox2.Text = Convert.ToString(drvSampleData["TestColumn2"]); TextBox2.Attributes["onchange"] ="javascript:SetRowChanged(" + e.Item.ItemIndex +")"; TextBox2.Attributes["onfocus"] ="javascript:CheckRowChanged('" + Repeater1.UniqueID +"', '" + TextBox1.ClientID +"', " + e.Item.ItemIndex +")"; TextBox TextBox3 = (TextBox)e.Item.FindControl("TextBox3"); TextBox3.Text = Convert.ToString(drvSampleData["TestColumn3"]); TextBox3.Attributes["onchange"] ="javascript:SetRowChanged(" + e.Item.ItemIndex +")"; TextBox3.Attributes["onfocus"] ="javascript:CheckRowChanged('" + Repeater1.UniqueID +"', '" + TextBox1.ClientID +"', " + e.Item.ItemIndex +")"; } }protected override void RaisePostBackEvent(System.Web.UI.IPostBackEventHandler sourceControl,string eventArgument) {if ((eventArgument !=null) && (eventArgument.Contains("SaveData$"))) {// Do nothing }else {base.RaisePostBackEvent(sourceControl, eventArgument); } }}

default2.aspx - UpdatePanel contains Repeater control, client-side JavaScript included using ScriptManager.RegisterClientScriptInclude method

-- default2.aspx

<%@dotnet.itags.org. Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="_Default2" %><!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> This is some text sitting outside the main control. It should not be refreshed by AJAX.<%=DateTime.Now%><br /> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" /> <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="conditional"> <ContentTemplate> <asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="Repeater1_ItemDataBound" > <HeaderTemplate> This is inside the update panel and should be updated.<%=DateTime.Now%><br /> </HeaderTemplate> <ItemTemplate> <asp:TextBox ID="TextBox1" runat="server" />  <asp:TextBox ID="TextBox2" runat="server" />  <asp:TextBox ID="TextBox3" runat="server" /><br /> </ItemTemplate> </asp:Repeater> </ContentTemplate> </asp:UpdatePanel> </form></body></html>

-- default2.aspx.cs

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 _Default2 : System.Web.UI.Page {protected void Page_Load(object sender, EventArgs e) {if(!IsPostBack) {if (!ClientScript.IsClientScriptIncludeRegistered("SingleRowUpdate")) { ScriptManager.RegisterClientScriptInclude(this,typeof (Page),"SingleRowUpdate","JScript.js"); } BindData(); }else {if (Request.Form["__EVENTTARGET"].Contains(Repeater1.UniqueID.Replace(':','$'))) {if (Request.Form["__EVENTARGUMENT"].Contains("SaveData$")) {string[] aszSaveParameters = Request.Form["__EVENTARGUMENT"].Split('$');string szCurrentControlID = aszSaveParameters[1];int iSaveItemIndex = Convert.ToInt32(aszSaveParameters[2]);int iCurrentRowIndex = Convert.ToInt32(aszSaveParameters[3]); RandomizeRow(iSaveItemIndex); ScriptManager1.SetFocus(szCurrentControlID); } } } }private void RandomizeRow(int index) { RepeaterItem riSaveRow = Repeater1.Items[index]; Random oRandom =new Random(); TextBox TextBox1 = (TextBox)riSaveRow.FindControl("TextBox1"); TextBox1.Text = Convert.ToString(oRandom.Next()); TextBox TextBox2 = (TextBox)riSaveRow.FindControl("TextBox2"); TextBox2.Text = Convert.ToString(oRandom.Next()); TextBox TextBox3 = (TextBox)riSaveRow.FindControl("TextBox3"); TextBox3.Text = Convert.ToString(oRandom.Next()); }private void BindData() { Repeater1.DataSource = GetSampleData(); Repeater1.DataBind(); }private DataTable GetSampleData() { DataTable dtbSampleData =new DataTable(); dtbSampleData.Columns.Add("TestColumn1",typeof(string)); dtbSampleData.Columns.Add("TestColumn2",typeof(string)); dtbSampleData.Columns.Add("TestColumn3",typeof(string)); DataRow drSampleData = dtbSampleData.NewRow(); drSampleData["TestColumn1"] ="column 1, row 1"; drSampleData["TestColumn2"] ="column 2, row 1"; drSampleData["TestColumn3"] ="column 3, row 1"; dtbSampleData.Rows.Add(drSampleData); drSampleData = dtbSampleData.NewRow(); drSampleData["TestColumn1"] ="column 1, row 2"; drSampleData["TestColumn2"] ="column 2, row 2"; drSampleData["TestColumn3"] ="column 3, row 2"; dtbSampleData.Rows.Add(drSampleData); drSampleData = dtbSampleData.NewRow(); drSampleData["TestColumn1"] ="column 1, row 3"; drSampleData["TestColumn2"] ="column 2, row 3"; drSampleData["TestColumn3"] ="column 3, row 3"; dtbSampleData.Rows.Add(drSampleData); drSampleData = dtbSampleData.NewRow(); drSampleData["TestColumn1"] ="column 1, row 4"; drSampleData["TestColumn2"] ="column 2, row 4"; drSampleData["TestColumn3"] ="column 3, row 4"; dtbSampleData.Rows.Add(drSampleData); drSampleData = dtbSampleData.NewRow(); drSampleData["TestColumn1"] ="column 1, row 5"; drSampleData["TestColumn2"] ="column 2, row 5"; drSampleData["TestColumn3"] ="column 3, row 5"; dtbSampleData.Rows.Add(drSampleData); dtbSampleData.AcceptChanges();return dtbSampleData; }protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e) {if((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem)) { DataRowView drvSampleData = (DataRowView) e.Item.DataItem; TextBox TextBox1 = (TextBox)e.Item.FindControl("TextBox1"); TextBox1.Text = Convert.ToString(drvSampleData["TestColumn1"]); TextBox1.Attributes["onchange"] ="javascript:SetRowChanged(" + e.Item.ItemIndex +")"; TextBox1.Attributes["onfocus"] ="javascript:CheckRowChanged('" + Repeater1.UniqueID +"', '" + TextBox1.ClientID +"', " + e.Item.ItemIndex +")"; TextBox TextBox2 = (TextBox)e.Item.FindControl("TextBox2"); TextBox2.Text = Convert.ToString(drvSampleData["TestColumn2"]); TextBox2.Attributes["onchange"] ="javascript:SetRowChanged(" + e.Item.ItemIndex +")"; TextBox2.Attributes["onfocus"] ="javascript:CheckRowChanged('" + Repeater1.UniqueID +"', '" + TextBox1.ClientID +"', " + e.Item.ItemIndex +")"; TextBox TextBox3 = (TextBox)e.Item.FindControl("TextBox3"); TextBox3.Text = Convert.ToString(drvSampleData["TestColumn3"]); TextBox3.Attributes["onchange"] ="javascript:SetRowChanged(" + e.Item.ItemIndex +")"; TextBox3.Attributes["onfocus"] ="javascript:CheckRowChanged('" + Repeater1.UniqueID +"', '" + TextBox1.ClientID +"', " + e.Item.ItemIndex +")"; } }protected override void RaisePostBackEvent(System.Web.UI.IPostBackEventHandler sourceControl,string eventArgument) {if ((eventArgument !=null) && (eventArgument.Contains("SaveData$"))) {// Do nothing }else {base.RaisePostBackEvent(sourceControl, eventArgument); } }}

-- JScript.js

// JScript Filevar currentRowChanged = -1;function SetRowChanged(rowIndex){ currentRowChanged = rowIndex;}function CheckRowChanged(repeaterUniqueID, controlID, newRowIndex){if((currentRowChanged != -1) && (currentRowChanged != newRowIndex)) { saveInfo ='SaveData$' + controlID +'$' + currentRowChanged +'$' + newRowIndex; currentRowChanged = -1; __doPostBack(repeaterUniqueID, saveInfo); } }

web.config - project web config file

<configuration><configSections><sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"><sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"><section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/><sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"><section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere"/><section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/><section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/></sectionGroup></sectionGroup></sectionGroup></configSections><system.web><pages><controls><add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/></controls></pages><!-- Set compilation debug="true" to insert debugging symbols into the compiled page. Because this affects performance, set this value to true only during development. --><compilation debug="true"><assemblies><add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/></assemblies></compilation><httpHandlers><remove verb="*" path="*.asmx"/><add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/><add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/><add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/></httpHandlers><httpModules><add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/></httpModules></system.web><system.web.extensions><scripting><webServices><!-- Uncomment this line to customize maxJsonLength and add a custom converter --><!-- <jsonSerialization maxJsonLength="500"> <converters> <add name="ConvertMe" type="Acme.SubAcme.ConvertMeTypeConverter"/> </converters> </jsonSerialization> --><!-- Uncomment this line to enable the authentication service. Include requireSSL="true" if appropriate. --><!-- <authenticationService enabled="true" requireSSL = "true|false"/> --><!-- Uncomment these lines to enable the profile service. To allow profile properties to be retrieved and modified in ASP.NET AJAX applications, you need to add each property name to the readAccessProperties and writeAccessProperties attributes. --><!-- <profileService enabled="true" readAccessProperties="propertyname1,propertyname2" writeAccessProperties="propertyname1,propertyname2" /> --></webServices><!-- <scriptResourceHandler enableCompression="true" enableCaching="true" /> --></scripting></system.web.extensions><system.webServer><validation validateIntegratedModeConfiguration="false"/><modules><add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/></modules><handlers><remove name="WebServiceHandlerFactory-Integrated"/><add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/><add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/><add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/></handlers></system.webServer></configuration>
Ok, here is a little secret about Update panel!Update panel posts back everything as in traditional .NET 1.1 Post back.Only at the rendering on the server does it realizes that it would only need to send what is in the update panel and sends only that part as response.So, your request is same as the post-back model. Only your response is minimized.I guess what you should be doing is making a call to Web Service or Web Method in a page and use JSON for serialization.

This way you would only send what you need to send and get back what is necessary...but you would have to write some Java Script :)


I can understand what you are saying to a certain degree. Indeed that is something to look into (and something to argue about with developers that don't like JavaScript) for performance increases. Thanks, Ravivb, for the info. I was not aware of JSON.

Unfortunately, there is still the root problem I'm having with AJAX. Somehow the server is not recognizing that it needs to refresh only a certain portion of the page. It is re-rendering everything. In the sample provided, the time outside the UpdatePanel is updated along with the time inside the UpdatePanel on every row change. Thus AJAX does not appear to be working at all on this page, as everything is posting back and being refreshed, rather than just the section inside the UpdatePanel.

Also, I don't understand why the JavaScript can't be loaded from a JavaScript .js file. It shouldn't make any difference if the JavaScript is embedded in the page or if it is being included from a file. But for some reason there is a difference.

Jeff


I have not followed your entire code to give proper answer on JavaScript problem.

But, if i were you, i would start at looking in to java script file path mapping to see if the path mapping is done right once the html is sent to client..

Next, try to debug java script to see what is going on. (you could use Firebug for FF or IE developer Toolbar fromhere

-good luck


Kalnir,

try looking into webservice. I have a few pages that are huge, doing postback on them is a pain in the b**t. Your webservice can be called from your javascript function.


Thanks, Ravivb and WishStar99. I just read up on JSON and the ASP.NET callback event technique, and I'm starting to work on constructing a test version of the page using the technique. I'll keep the webservice call in mind as well.

I'm not sure that will fix the problem I'm having with Repeater inside UpdatePanel, though. Any idea why the whole page is flashing instead of just the UpdatePanel region?


Heya, folks.

I want to thank Ravivb and WishStar99 for their help with this problem. The application was modified to use JSON and the ASP.NET callback event technique. The solution appears to be working fine and is fast enough to be acceptable to the end users.

The following articles helped me learn about JSON and how to work with it in .NET:

JSON (JavaScript Object Notation) data interchange format: http://json.org/


Glad it worked out...


Hi Jeff,

Can you show me in which article I can see some code sample for refreshing the gridView single row, as u did instead of using updatepanels.

I can t find some code sample where I refer the gridview or datagrid's single row.

Anyway, can u show us some code sample pls for doing what u did. i didn t find that on internet. I m not talking about calling the webmethod but especially m talking about the javascript DOM part that takes the result send by the webmethod and refreshes the datagrid or gridview's single row.

Thanks a lot.


Very interesting info on the JSON stuff.

I wanted to mention that I have almost successfully implemented a fully Ajax website using asp.net 2.0, however with one major problem. I have a Repeater object inside the UpdatePanel control, but everytime the Timer control kicks fires the asynch update it freezes up all of the page controls (i.e. hyperlinks, dropdownlists, etc.).

I have an update image that flashes with every Asynch update; and everytime the image appears I cannot click on any links nor access the dropdown lists. It's very frustrating.

Has anyone experiences this with a Repeater inside an UpdatePanel ? Any advice or ideas ?

Thank you very much,

Bob

AJAX UpdatePanel and Validators - Framework Updated?

Hi Folks,

I bumped into the updatepanel/validator control issue yesterday and solved the problem by grabbing the updated validators project as per the pinned post at the top of this forum (http://forums.asp.net/t/1066821.aspx).

That said, in the post and in Scott Guthrie's blog there is mention of an official patch to ASP.NET 2.0 to fix this issue which would go out via windows update. Did this ever happen? My own dev box certainly doesn't seem to be fixed (hence having to use the compatibility validators downloaded from mattgi's site).

Cheers

Kev

I think it has because I do not have the Validator issue and I am not using the Validator library anymore. But do not hold me to it, I may have just prayed real hard for effective validation. I also like the MaskedEditValidator control too, you should check it out.


I feel like a real shoe for using someone elses code and not understanding what it's doing...

I hope I can find time to view this guys source... :(


Wow, this actually did not fix my issue -- but I know I'm using validators in the an updatepanel an getting the same issue. Grrr...


Hello.

if i'm not mistaken, you'll only get compatible validators on the 3.5 framework since the validators of 2.0 were never updated to be compatible with the updatepanel.

ajax update progress control with FileUpload control

Hi,

There has been a lot of posts about this in other communities as well as in asp.net forum.But I am not getting a correct picture.

By default,the fileupload and Ajax update panel does not go together,I am using a trigger where the postback trigger id is pointing to a button,which initiates the file upload.I have put an update progress control also.

But I am not seeing the update progress and the ajax behaviour is not consistent(actually its not getting).Can someone throw a light into this?

Regards

Ajith

Hi,

since you have activated the postback trigger of the update panel,it will act as a normal form and you will lose the benefit of asynchrounous effet.So,the update progress control will have no effect in this case since all the page is posted back.

In fact,this the only walkaround (that I have found) to use the fileuplod control inside an update panel.

Hope that this help you.


Hi,

So there is no point in using ajax technology there right.....

Regards

Ajith

Ajax Update Panel question

Is it possible to place an update panel (or some other ajax control) on a non .aspx page? I am trying to build a poll application to use on our content pages. Unfortunately our content pages are just straight up html pages and do not run through the .net server. In fact asp.net isn't even installed on that server and likely can't be. Is it possible to have something on an html page redirect itself to the asp.net server?

I know this can't be done with regular asp.net controls but i thought perhaps the Ajax update panel would work?


If that wouldn't work is there another alternative, that still uses the .net framework?

I've seen other polling applications that let you copy and paste a simple line of javascript code onto their blogs or html pages,etc. And this piece of javascript communicates with the poll service. I was wondering if asp.net had a similar solution.

Jay

Hey,

Not on HTML pages no, only with ASPX pages. If you are using HTML, you could download the client solution they created off of the ajax.asp.net. It is the client-side libraries they used, which you can use that in HTML no problem.


Take a look at the Microsoft Ajax Library

http://ajax.asp.net/downloads/default.aspx

http://aspnetresources.com/blog/ms_ajax_cheat_sheets_batch1.aspx

ok thanks. I looked at these and its a start, although it looks pretty overwhelming for a newbie. I don't know where to begin.

I believe this is the online documentation for the client libraries correct?

http://ajax.asp.net/docs/ClientReference/default.aspx

Off-hand would you happen to know of any websites or tutorials or that would explain how to use the client libraries a little better?

Jay


This blog entry has an example and some links

http://blogs.msdn.com/brada/archive/2006/10/23/microsoft-ajax-library-at-the-ajax-experience.aspx

In fact asp.net isn't even installed on that server and likely can't be.

AJAX.net is based on theXMLHttpRequest, which works only for the same domain, AKA sandbox. Depending on your network anupdatepanel based on MicrosoftAjax.js may be very complex to implement. It is easier to haveHTML and.net on one server only.

Is it possible to have something on an html page redirect itself to the asp.net server?

Solution A: you can (re-)direct the user to your poll server in using a simplelink or the Javascriptlocation object.


B and C are likely the paths i will take i think. I've played around with the IFRAME and it seems to work well. I was trying to avoid it but i guess its not so bad. Thanks.

J

AJAX Update Panel in ASCX Control

Hi All - I have searched for and read about every post concerning using the AJAX library in an ASCX control and I am at a loss. I sure hope someone can help me figure out how to get it to work.

I am dynamically adding ASCX controls to my page using the Page.LoadControl method and it works fine. I have an Update Panel containing a TextBox control that I try to access from the ASPX page but it says it does not exist. I even have a property that specificallt returns the text box for me. When I Debug I look at the Update Panel and it is there with one control. That control is a Content Template and it has 0 controls. I don't know where my TextBox has gone. I wanted to get a handle on it so that I could add an event handler.

I have tried several other approaches inclusing dynamically adding the control to the update panel at run time and that failed miserably. Does anyone have any suggestions?

Any help is appreciated. Thanks!

DK

Try creating your dynamic controls in Page_Init event handler (same signature as Page_Load). Most problems like this have to do with the fact that code executed on postbacks, such as button click handler, is called before Page_Load, thus before your dynamic controls are recreated. Another good reason to have your controls created in Page_Init: only then they participate in ViewState restoration (as long as you assign them with the same ID in all the roundtrips).

Thanks for the suggestion. I will give that a try and post back the results.


That did not work unfortunately. The TextBox is still not there when I try to add a Handler.

I did want to add some additional information that may or may not help. My TextBox controls on the ASPX page that are inside of Update Panels work perfectly so my web and everything else is configured properly. It is just the use in an ASCX control that is not working.

I have read many other posts in this newsgroup with the same issue but I am not seeing anyone posting a real resolution as far as I can tell. Does the AJAX team at MS have any perspecitve or guidance on this?

Thanks,

DK


Could you please submit a minimal code sample where the problem appears? I'd give it a try...

I am having the same problem, this is some sample code:

In the User Control ascx

<%@.ControlLanguage="VB"AutoEventWireup="false"Inherits="ucCalendarWithTextBox"Codebehind="ucCalendarWithTextBox.ascx.vb" %>

<%--Dynamic atlas updatepanel is possible as of June 2006, we still haven't download that yet--%>

<%@.RegisterAssembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

Namespace="System.Web.UI"TagPrefix="asp" %>

<

asp:UpdatePanelID="up2"runat="server"><Triggers><asp:AsyncPostBackTriggerControlID="CalendarPicker"EventName="SelectionChanged"/></Triggers><ContentTemplate><asp:TextBoxID="TxtDate"runat="server"Width="120"ReadOnly="false"AutoPostBack="true"></asp:TextBox></ContentTemplate>

</

asp:UpdatePanel>

In an aspx page

Dim

calFromAs UcCalendarWithTextBox = Page.LoadControl("../UcCalendarWithTextBox.ascx")

The problem is:

calFrom.TxtDate = Nothing. i.e. I can't find the controls in my contenttemplate


Sure - Here is the code for my ASX control:

-----------------------------

<%

@.ControlLanguage="vb"AutoEventWireup="false"CodeBehind="MCAProducerBasePercentControl.ascx.vb"Inherits="MCAWeb.MCAProducerBasePercentControl" %>

<

tableid="tblProducerBasePercent"runat="server"><tr><tdalign="left"style="width: 75px"><asp:UpdatePanelID="upProducerID"runat="server"><ContentTemplate><asp:TextBoxID="txtProducerID"runat="server"Width="75px"></asp:TextBox></td></ContentTemplate></asp:UpdatePanel></td><tdalign="left"style="width: 115px"><asp:TextBoxID="txtCommissioningID"runat="server"Width="115px"></asp:TextBox></td><tdalign="left"style="width: 75px"><asp:TextBoxID="txtAmount"runat="server"Width="75px"></asp:TextBox></td><tdalign="left"style="width: 75px"><asp:TextBoxID="txtRate"runat="server"Width="75px"></asp:TextBox></td><tdalign="left"style="width: 45px"><asp:ButtonID="btnAddOrDelete"runat="server"Text="Add"Width="45px"/></td></tr>

</

table>

-----------------------------

In my code behind of the ASCX control, I have a property that returns the TextBox located inside of the UpdatePanel:

-----------------------------

Public

ReadOnlyProperty ProducerID()As TextBoxGetReturn txtProducerIDEndGetEndProperty

-----------------------------

I then load the control at some point in my ASPX page:

-----------------------------

producerControl = Page.LoadControl("~/MCAProducerBasePercentControl.ascx")

-----------------------------

Then when I try to access the property and get the text box to add a handler dynamically it fails because it cannot see the Text Box:

-----------------------------

AddHandler

CType(producerControl, MCAProducerBasePercentControl).ProducerID.TextChanged,AddressOfMe.HandleExternalIDValidation

-----------------------------


As an update, I decided to try creating the TextBox control on the fly in the ASPX page, adding the Event Handler and the adding it to the Controls collection of the ContentTemplateContainer object inside of the UpdatePanel. For example:

CType

(producerControl, MCAProducerBasePercentControl).ProducerIDUpdatePanel.ContentTemplateContainer.Controls.Add(txtTest)When the page is rendered the event still does not fire off however I am seeing that it appears to have registered all of the update panels, inlcuding the one contained in my dynamically added ASCX control (highligted below in bold):

//<![CDATA[
Sys.WebForms.PageRequestManager._initialize('ScriptManager1', document.getElementById('frmMCADetail'));
Sys.WebForms.PageRequestManager.getInstance()._updateControls(['tUpdatePanel2','tUpdatePanel1','tctl06$upProducerID'], [], [], 90);
//]]>

However, I also notice that the above reference does not match the actual ID of the panel:

(NOTE: a 't' has been added to all of the UpdatePanel ID names in the above PageRequestManager. I am referring to the '$' versus the underscore character)

<div id="ctl06_upProducerID">
<input name="ctl06$txtTest" type="text" onchange="javascript:setTimeout('__doPostBack(\'ctl06$txtTest\',\'\')', 0)" onkeypress="if (WebForm_TextBoxKeyHandler(event) == false) return false;" id="ctl06_txtTest" />
</div>

In my other UpdatePanels, the ID matches and everything works great. Here is an example:

<div id="UpdatePanel1">
<input name="txtContractAccount" type="text" onchange="javascript:setTimeout('__doPostBack(\'txtContractAccount\',\'\')', 0)" onkeypress="if (WebForm_TextBoxKeyHandler(event) == false) return false;" id="txtContractAccount" style="width:100px;" />
</div>

Is this perhaps my problem at least in terms of this approach of adding the TextBox on the fly and the event not firing off?


Just a guess: maybe you both forget to add the dynamically created user control to some container on the page? Page.LoadControl only is not enough! I re-created the sample on my workstation (in C#), and it works fine, assuming it's done like this:

ASCX code:
<%@. Control Language="C#" AutoEventWireup="true" CodeFile="CalendarWithTextBox.ascx.cs" Inherits="CalendarWithTextBox" %>
<%@. Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI" TagPrefix="asp" %>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:TextBox ID="TxtDate" runat="server" Width="120px" ReadOnly="false" AutoPostBack="true"></asp:TextBox>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="TxtDate" />
</Triggers>
</asp:UpdatePanel>


Code-behind of user control:
public partial class CalendarWithTextBox : System.Web.UI.UserControl
{
public string Date
{
get
{
return TxtDate.Text;
}
set
{
TxtDate.Text = value;
}
}
}

and finally, the code-behind of the page
private CalendarWithTextBox Calendar;

protected void Page_Init(object sender, EventArgs e)
{
Calendar = Page.LoadControl("CalendarWithTextBox.ascx") as CalendarWithTextBox;
form1.Controls.Add(Calendar);
}

protected void Page_Load(object sender, EventArgs e)
{
Calendar.Date = String.Format("{0:dd.MM.yyyy}", DateTime.Now);
}

User control is loaded in Page_Init with purpose, as only then it properly participates in page viewstate, and your controls are ready when handling postback events (Page_Load happens after your button click handlers, for example!)


Good thinking but of course I have added the control to the Page. It shows up just fine once it is rendered. The control is just dead...I believe it is related though to both techniques I mention above in my previous posts. Not only can I not see the control to add an event handler, when I add a control on the fly and add to the UpdatePanel the ID's are mismatched anyway.

You seem to be really stuck on this idea of Page_Init which I kind of understand but 1) I have never had issues with just firing off my routines in the Page_Load event and things working fine and 2) this is not an issue related to loading the ASCX control. This is an issue with using the Ajax UpdatePanel in a user control.

So I will ask again, is there a member of the MS team that can say whether or not definitively if Ajax can be used with a user control loaded using ASCX and Page.LoadControl()?

Thanks!

DK


There is nothing that forbids using update panel combined with dynamically loaded controls. Done that many times. Not without problems, there is always something new to discover about AJAX, but it does work.

Nevertheless, I've committed a small sample in VB, looking like your scenario (user control with update panel, loaded dynamically, with control whose events handlers are provided by the containing page). Here it just works! I hope this will be helpful. For some reasons I can't submit attachments, so I provide complete code down here in the post. Create a new empty AJAX website (VB), then copy'n'pastedefault.aspx andmycontrol.ascx files listed below.

And indeed, preaching the use of Page_Init has become a kind of a personal obsession, after seeing so many people getting into trouble because of ignoring the page event sequence ...

MyControl.ascx
<%@. Control Language="VB" AutoEventWireup="false" CodeFile="MyControl.ascx.vb" Inherits="MyControl" %>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true" UpdateMode="Always">
<ContentTemplate>
Type some text:<br />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><asp:Button ID="Button1" runat="server" Text="Ok" Width="65px" />
</ContentTemplate>
</asp:UpdatePanel>

MyControl.ascx.vb
Partial Class MyControl
Inherits System.Web.UI.UserControl

Public Property Text() As String
Get
Return TextBox1.Text
End Get
Set(ByVal value As String)
TextBox1.Text = value
End Set
End Property

Public ReadOnly Property OkButton() As Button
Get
Return Button1
End Get
End Property

End Class

Default.aspx
<%@. Page Language="VB" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<%@. Register src="http://pics.10026.com/?src=MyControl.ascx" TagName="MyControl" TagPrefix="uc1" %>
<!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" EnablePartialRendering="true" />
<asp:UpdatePanel ID="UpdatePanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel ID="panelControls" runat="server">
</asp:Panel>
<asp:Panel ID="panelResult" runat="server">
<asp:Label ID="LabelResult" runat="server" Text="-"></asp:Label><br />

</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>

Default.aspx.vb
Partial Class _Default
Inherits System.Web.UI.Page

Private control As MyControl

Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
control = CType(Page.LoadControl("~/MyControl.ascx"), MyControl)
panelControls.Controls.Add(control)
AddHandler control.OkButton.Click, AddressOf Me.ButtonOk_Click
End Sub

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If (Not Page.IsPostBack) Then
control.Text = "Hello"
End If
End Sub

Protected Sub ButtonOk_Click(ByVal sender As Object, ByVal e As System.EventArgs)
LabelResult.Text = "You've entered: " & control.Text
UpdatePanel.Update()
End Sub

End Class


Thanks much for the sample. I will follow your advice and try your sample project to see if I can get the same results. Perhaps it will show me something obvious I am missing.

On the Page_Init thing, I understand your sentiment and very much appreciate your effort. I really appreciate the help you have given me thus far.

DK


Well I think I finally got it working properly. I think your solution offered me a couple of insights.

First, I did have to add the dynamically loaded control to a Controls collection of some control on the page before I could add a handler. Perhaps that is what you were saying earlier but I took your post that you were asking if I was adding the ASCX control to the page at all. Anyway, once I added it to the Table's Control collection on my Page, I was able to access the TextBox and add a handler.

Secondly, your example made me realize that I was not rendering the controls again on a post back. I am not sure how I missed that one ;-) I have a need for controls to be dynamically loaded both on a selection from a dropdown and when someone clicks an Add button. I will need to place that added data in session somewhere and then load it each time so that when the partial page postback occurs it will add the handler again and everything will be wired up since these controls are not statically added to the page at design time and I don't have anything in Viewstate for them (unless I am missing something?).

I also decide to follow your advice on using Page_Init and it has prompted me to revisit the page life cycle text again to make sure I am up to speed.

I don't know if this thread is finished and I am not sure which post to mark as having the answer. Thanks again for your help and I will post if I have any updates.

DK


Nice to hear that, I hope you will get the remaining issues solved too.

As for adding controls - it indeed needs to be added to the ASP.NET form control, or somewhere within it's scope. Same in design time - if you place a control outside of <form> tag, you will also get a nasty runtime error.

If you create the user control in Page_Init and assign it with an explicit and always the same server-side ID, you do not need to preserve the drop down list items in a session or stuff. Just add the new items to DropDownList.Items collection whenever you need it, and they will be preserved in the viewstate and assigned back to your dropdown on postbacks. It does not make a difference if you make a control dynamically or design time - as long as you do it in a right sequence, they all can make use of the view state.

It seems that we've exhausted the issue, so feel free to close the thread any time!


Hi guys,

Just wanted to add my issue and what I discovered I had to do.

I'm dynamically loading a bunch of ascx controls into tables that are created by ascx controls.
Pseudocode

for each ctl in list of control definitions loaded from an xml file (or database)
create an ascx ctl (that has an update panel in it) with loadcontrol (this could be a control which would cause this loop to be executed for the controls in that control basically a panel with panels in it)
set some values
add to this control's table control.
loop

on post back, I get an error of cannot find ctl named ddValue for displayPanel trigger.
I think the problem occurs because the top ascx control isn't added to the main Page controls until after all the sub controls are added and when it gets to the postback control, it's trying to add it to a control that hasn't been added to the page yet. weird thing is it doesn't cause any problem when it loads the first time it's only on postback.

I fixed it by assigning the trigger in the code for the ascx load event instead of declaratively on the ascx page.

AJAX update panel

Dear ALL;

I have a problem in the updatepanel.

I put a scriptmanager the an updatepanel.in the updatepanel i put a timer control and a label.

all what i need is to update the label with current time.

the code i write is

protectedvoid Page_Load(object sender,EventArgs e)

{

if (!Page.IsPostBack)

{

DateLabel.Text =DateTime.Now.ToString();

}

}

protectedvoid DateTimer_Tick(object sender,EventArgs e)

{

DateLabel.Text =DateTime.Now.ToString();

}

but it gives me a javascript error

Line: 184

char:1

code:0

Error: 'Sys' is undefined

when i view the source of the page i found the source of the error is this statement

Sys.Application.initialize();

What is theSYS?

Thanks in advance...

Make sure you have the following config section in your web.config

<

httpHandlers>
<removeverb="*"path="*.asmx"/>
<addverb="*"path="*.asmx"validate="false"type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<addverb="*"path="*_AppService.axd"validate="false"type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<addverb="GET,HEAD"path="ScriptResource.axd"type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"validate="false"/>
</httpHandlers>

AJAX treeview control

Does anyone have an example of building a dynamic checkbox treeview control using AJAX? I'd appreciate any pointers.

Thx,

-M

Treeviews aren't supported by the UpdatePanels in the current release of ASP.NET Ajax. I have heard that you can do this in the render event, but it would be very hacky. There are some 3rd party controls that handle that.

Monday, March 26, 2012

Ajax Toolkit, calendar extender control

I have troubles with calendar control. When I tryed to run site with this control in Visual Studio i see the correct language - russian, but when i tryed to run deployed site using iis, i see english - names of months, days header.

i tryed to write in config files globalisation, ui culture, add charset win-1251, but no differences. i see only english words.

Have you set the EnableScriptGlobalization property to true in the scriptmanager?

yes


Hi

You should specifily its Culture and UICulture. Furture more, you should set ScriptManager's EnableScriptGlobalization and EnableScriptLocalization property to true.

EnableScriptLocalization: http://www.asp.net/AJAX/Documentation/Live/mref/P_System_Web_UI_ScriptManager_EnableScriptLocalization.aspx

EnableScriptGlobalization: http://www.asp.net/AJAX/Documentation/Live/mref/P_System_Web_UI_ScriptManager_EnableScriptGlobalization.aspx

Here is the sample.

<%@. Page Language="C#" Culture="ru-RU" UICulture="ru"%><%@. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"></script><html xmlns="http://www.w3.org/1999/xhtml"><head id="Head1" runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" EnableScriptGlobalization="true" EnableScriptLocalization="true" > </asp:ScriptManager> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><asp:Button ID="Button2" runat="server" Text="hide" OnClientClick="return hideCalendar()"/> <asp:Button ID="Button1" runat="server" Text="show" OnClientClick="return false;"/> <ajaxToolkit:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="TextBox1" PopupButtonID="Button1" > </ajaxToolkit:CalendarExtender> </form></body></html>

I hope this help.

Best regards,

Jonathan

Ajax Toolkit issue with web deploy project in Visual Studio 2005

Error 157 Unable to copy file "C:\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\AJAX Control ToolKit\SampleWebSite\Bin\zh-CHT\AjaxControlToolkit.resources.dll" to "C:\Documents and Settings\UserName\My Documents\Visual Studio 2005\Projects\TipWebCurrent\TipWeb\Bin\zh-CHT\AjaxControlToolkit.resources.dll". Access to the path 'C:\Documents and Settings\UserName\My Documents\Visual Studio 2005\Projects\TipWebCurrent\TipWeb\Bin\zh-CHT\AjaxControlToolkit.resources.dll' is denied. 1 1 TipWeb_deployProject

I am getting the above problem when I try and build my solution,(web deploy project specifically) is it as simple as changing the properties of the read-only access for each folder to false for each of the folders containing the dll's?


Yes, the directory that you are publishing to or at least the bin should have right access until you are done deploying, then make it read only again.


Yep, that was the main issue... Once I changed the permissions it worked like a charm!

:)

Ajax toolkit has a treeview control or not

Hi all,

Is there a treeview control inthe ajax toolkit if yes then send me the link

Thanks

Hi,

Read this, may be it can help you :

http://codeclimber.net.nz/archive/2007/06/28/Ajax-TreeView.aspx

Sincerely,

Cédric


There is no TreeView control available in AJAX Control Tookit.

AJAX Toolkit errors

Hi,

I'm not habving much look with the ajax control toolkit.

1 - I was getting intellisense errors and

Changing

<add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
namespace="System.Web.UI"
tagPrefix="asp" />

to...

<add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
namespace="System.Web.UI"
tagPrefix="ajax" />


...seemed to fix those problems.

However, I still does not work. I'm using a test page with the autoCompleteExtender. When I compile and run, I get no compilation errors but two javascript errors in the browser (firefox 2.0):

"Sys is not defined"

Not impressed with lack of propper error reporting.

Anyone know what might be going on?


Br,

Scott

This is an error related with the js file which comes along with the Source code of AjaxToolKit, but i suggest u to use AjaxToolKit.dll instead.


Hi Scott,

First of all , we should know if we use an AJAX Control Toolkit control on the page , we shall first install ASP.NET AJAX Extensions then add reference to the AjaxControlToolkit.dll( or install the AJAX template). Please see these two video tutorials (Extensions, AJAX Control Toolkit.)

sosh:

Changing

<add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
namespace="System.Web.UI"
tagPrefix="asp" />

to...

<add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
namespace="System.Web.UI"
tagPrefix="ajax" />

Actually,

<controls>
<add namespace="AjaxControlToolkit" assembly="AjaxControlToolkit" tagPrefix="ajaxToolkit"/> <!-- register the AjaxControlToolkit -->
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, 1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> <!-- register the ASP.NET AJAX Extensions -->

sosh:

"Sys is not defined"

It is usually related to the Asp.net AJAX Extensions. We suggest that you should download a sample fromhttp://www.asp.net/learn/ajax-videos/ and have a glance of its source code and web.config settings.

I hope this help.

Best regards,

Jonathan

Ajax Toolkit Controls disabled

I downloaded ajasx control toolkit for .net 3.5 and added into separate tab in visual studio 2008 tolbox.

Problem is they are invisible (disabled when pres Show All in toolbox).

Anybody familiar with this issue?

Hi Ekaan,

Someone has met this kind of issue before. Please have a test by followingthis article.

This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

If it doesn't work, please feel free to let me know.

Best regards,

Jonathan


Thanks but that didn't help.
I can use them trough source (markup or C#) but it slows down my development :-(

I have same issue with Telerik prometheus controls.


Hi Ekaan,

ekaan:

Problem is they are invisible (disabled when pres Show All in toolbox).

Would you please describe your issue more clearly for us?

Best regards,

Jonathan

AJAX Toolkit CalendarExtender Issue

I am going to write a web application using AJAX Toolkit. In one of the application modules, I have to use calendar control. To meet this requirement I am using CalendarExtender with a TextBox control. I have a problem when I submit the form having this controls combination. The problem is that I am unable to get Text field value after submitting the form. I have written a sample page to make my point cleat to you. Here is the code:


<script runat="server">
protected void Button1_Click(object sender, EventArgs e)
{
string strDate = "";
strDate = txtCheckinDate.Text;
}

</script>

...

...

<div>

<asp:TextBox ID="txtCheckinDate" runat="server" ReadOnly="True"></asp:TextBox>
<asp:ImageButton ID="btnCalendar" runat="server" AlternateText="Click to show calendar" ImageUrl="~/images/Calendar_scheduleHS.png" />
<div style="font-size: 90%"><em>(Click the image button to open the calendar)</em></div> <br />
<ajaxToolkit:CalendarExtender ID="CalendarExtender1" runat="server" Format="MMMM d, yyyy" PopupButtonID="btnCalendar" Animated="true"
TargetControlID="txtCheckinDate"> </ajaxToolkit:CalendarExtender> <br />

<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /><br />
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>

</div>


Would you please help me to find out the cause of problem?

Waiting your kind reply.


I created my own...Works for me. I did notice a few thing.

The ScriptManager must appear before any control that needs it.

Your page should include something like this...

<%@. Register Assembly="AjaxControlToolkit, Version=1.0.10301.0, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

and your tag prefix should look something like this

 <cc1:CalendarExtender ID="CalendarExtender1" runat="server" Format="MMMM d, yyyy" PopupButtonID="btnCalendar" Animated="true" TargetControlID="txtCheckinDate"> </cc1:CalendarExtender>

I hope that helps.

AJAX toolkit "access denied" problem

I am redesigning a site to include AJAX. On a new page that I created that contains a Tab Control, when I copy the page to the site's server, why would I be getting an "access denied" problem for a page that allows anonymous users? When I remove all references and controls for AJAX, it works fine.

Thanks for the information

Some more information on this problem...it seems as if it may be an IIS permission problem. All the AJAX controls run fine on the development machine, but in examining the website even further, any page with interaction, like a textbox with a watermark, I am getting Access Denied errors. Any help on this problem would be appreciated.

ajax toolkit - tabpanel question

How can I control the height of the tab label? I have too many tabs to fit on my page, so I have put a <br /> tag in the heading. This works, but because the tab label itself is too thin, the rest of the label is not visible.

Hi,

You can use .ajax__tab_xp .ajax__tab_tab{height: 100px} property to set the height of the tab.

AJAX TOOLKIT - TAB CONTROL- scripts

I was watching the video about this control, its great, but i have got a lot of questions. First: Why is the script language javascript?. I have tried using vbscript but it showed me some errors, so its a must javascript for AJAX controls?.

Whats the diference btween type=text/javascript, and language=javascript.

Hi,

Basically, you can use vbscript to call functions defined in javascript library via call statement. But, in my opinion, it's rather annoying to try to achieve this, and strongly recommend you using javascript directly.

Imnoob007:

Whats the diference btween type=text/javascript, and language=javascript.

They are tags used be browser to detect what's the type of the script, and there is no significant difference between them.


The J in ajax stands for javascript... If you're not used to javascript, don't worry about it, it's easy to learn and there are millions of tutorials and always an answer when you google "javascript [key words]"

(http://www.w3schools.com/ is my favorite)


Thnx guys. thnx for ur time. Now im best informed :)

Ajax Tookit Tab Control

I am all excited to get going with AJAX,

I drag the Tab Container onto the page, the I try to drag the Tab Panel on to the page into the Container and can't do it. OK. change to code view Drag the Panel into the container; that works; add header text; render the page and I see a tab. Still pretty happy.

Now I try to drag a Gridview control into the Panel in code view, run the page get an error

Parser Error Message:Type 'AjaxControlToolkit.TabPanel' does not have a public property named 'GridView'.

Not happy!!

Move on, there was a Button in the demo, so lets try and drag that into the control. No! Error again

Parser Error Message:Type 'AjaxControlToolkit.TabPanel' does not have a public property named 'Button'.

O.K. how about a text box

Parser Error Message:Type 'AjaxControlToolkit.TabPanel' does not have a public property named 'TextBox'.

The Demos make this look very simple, So can anyone comment on why this is happening?

this is how a tabcontainer looks like

<ajaxToolkit:TabContainer ID="tabs" runat="server">
<ajaxToolkit:TabPanel ID="Panel1" runat="server">
<ContentTemplate>
<asp:Button ID="Button1" Text="Hit & Run" OnClick="DoSomething" runat="server" />
</ContentTemplate>
</ajaxToolkit:TabPanel>
</ajaxToolkit:TabContainer>

if this doesn't make sense, let see your code ...

Ajax timercontrol - ie6 freezes with high cpu over long period of time

Hi,

I'm using Ajax for ASP.NET (2.0) on a project. In this project I use the ajax timer control to refresh contents of an update panel.
The panel refresh happens every minute. (the content of the panel consists of information that is pulled out of a database).

All works fine so far, except that I noticed to have big issue with my pages. The page with the timer & updatepanel is opened continously for literally days. (so we could speak of long user sessions), and each minute it is refreshing.

When loaded in ie6 (I didn't try another browser, but ie6 is still the standard in my company, so no other choices), after a while, I start noticing a constant CPU load on the iexplore.exe process, and I don't mean during refresh, just while the page is static & not updating/refreshing. It starts of at 0%, then after half an hour, it's at 1%, a bit later 2% and so on...
After lots of hours (like one working day), I end up with an internet explorer session that is continously using as much CPU as it can have. And most of the time, ie6 just got frozen and isn't doing anything.

This is so bad. I made sure I stopped the timer before doing the updating & then restart the timer to avoid any problems in this area, but it still exists.

Did anyone notice this as well? Is there some kind of cure for it? Or am I doing anything wrong here?

Thanks!!

Here's a related post:http://forums.asp.net/p/1009453/1367209.aspx

-Damien


As suggested in that topic I have moved the ajax timer control & the progress bar out of the update panel, I have set the update panel trigger to the timer tick event.

I also disable the timer before refreshing & enable it again afterwards:

protected void tmrRefresh_Tick(object sender, EventArgs e)
{
tmrRefresh.Enabled =false;
((BasePage)Page).Refresh();
tmrRefresh.Enabled =true;
}

The timer interval is set at 1 minute

still I have this increasing CPU load (really little, but it exists) over time, like + 1% every hour (just when the page is static).

What is going on here? Any help?

EDIT: I'd like to add that all things mentioned in the topic you posted belong to the atlas extensions. I'm not using those, I'm using the Ajax 1.0 extensions...


Atlas was the pre-release name of ASP.NET AJAX 1.0; much of the content still holds true...

Your problem sounds like this issue is a leak with IE6 and JavaScript; did you try with IE7?

-Damien


I know that Atlas preceded Ajax extensions, I only wanted to make sure what I was using. I can imagine some stuff was changed from Atlas to Ajax...
As told in my initial post, ie6 is still the standard browser in our company, so trying ie7 will not help me.

But... I created a very simple ajax enabled web application today with just a timer that refreshes a text label every 5 seconds. The label held the current date & time.
I let it run for half a day and no constant CPU load whatshowever.

Does this mean that the increasing CPU stuff is hiding somewhere else, in the refresh procedure of my project?
If so, then why does a client gets a constant CPU load even when the page is not refreshing.
I thought the only thing that would happen on client side was waiting for the next timer tick... or am I wrong?


I don't know who accepted Damien's post as answer, but this problem is still open and I have yet to find a solution...Surprise

Saturday, March 24, 2012

AJAX Timer not Ticking in MasterPages

Hi,

I have a timer control of the new AJAX version released. When in a page that doesn't have any MasterPages the Timer works perfectly, however when you give a MasterPage to the Page the Timer never Ticks!!!... I put a ScriptManagerProxy in the aspx page and a ScriptManager in the MasterPage (followed exactly the example on this site), but still to no avail.

why is this ? is this a bug ? am I missing something else ? anyone encountered something the sort?

Thanks!

Can you post some code which doesn't work? What is a purpose of the ScriptManagerProxy? I wrote a simple example for Timer and master page and I didn't find any problems.

<%@. Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
CodeFile="Default2.aspx.cs" Inherits="Default2" Title="Untitled Page" %
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:Timer ID="Timer1" runat="server" Interval="5000">
</asp:Timer>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" OnLoad="Load_Some_Data" UpdateMode="Conditional">
<triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" />
</triggers>
<contenttemplate>
<p>Refresh number: <asp:Literal ID="lit1" runat="server">0</asp:Literal></p>
</contenttemplate>
</asp:UpdatePanel>
</asp:Content>

public partial class Default2 : System.Web.UI.Page
{
protected void Load_Some_Data(object sender, EventArgs e)
{
lit1.Text = GetSomeNumber();
}
private string GetSomeNumber()
{
int i;
if (!int.TryParse(lit1.Text, out i))
return "ERROR";
else
return (++i).ToString();
}
}


Hello and thanks for the reply..

Try this: the Timer has to start Disabled and Enable it at runtime by a click event or so... also I'm seeing you don't have a Tick event!?


Here is a solution when Timer is by default disabled and during runtime enabled. I don't have tick event because updatepanel is refreshed every 5 seconds and on every refresh method Load_Some_Data is executed. What are you doing in your tick event and it can't be done this way?

<%@. Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:Timer ID="Timer1" runat="server" Interval="5000" Enabled="false">
</asp:Timer>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" OnLoad="Load_Some_Data" UpdateMode="Conditional">
<triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" />
</triggers>
<contenttemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<p>Refresh number: <asp:Literal ID="lit1" runat="server">0</asp:Literal></p>
</contenttemplate>
</asp:UpdatePanel>

<asp:Button ID="Button1" runat="server" Text="Enable Timer" OnClick="Button1_Click" />
</asp:Content>

public partial class Default3 : System.Web.UI.Page
{
protected void Load_Some_Data(object sender, EventArgs e)
{
lit1.Text = GetSomeNumber();
TextBox1.Text = lit1.Text;
}
private string GetSomeNumber()
{
int i;
if (!int.TryParse(lit1.Text, out i))
return "ERROR";
else
return (++i).ToString();
}
protected void Button1_Click(object sender, EventArgs e)
{
Timer1.Enabled = true;
}
}


hey thanks bsebo for following my case...

currently I don't have my code in front have to get home. 3hrs more :\....

basically the situation is this: A ScriptManager in the MasterPage, ScriptManagerProxy in the Page. A disabled Timer on the Page and on Button click event is gets Enabled. Ok it gets "Enabled" BUT the Tick Event is never executed.. .while without a MasterPage it gets executed. I need to work with the Tick event as I'm doing some process on the Tick event and thats it! ... I will post the code when I get back home.

Thanks again!


<%

@.PageLanguage="C#"MasterPageFile="~/MasterPage.master"AutoEventWireup="true"CodeFile="Default2.aspx.cs"Inherits="Default2"Title="Untitled Page" %>

<

asp:ContentID="Content1"ContentPlaceHolderID="ContentPlaceHolder1"Runat="Server"><asp:ScriptManagerid="ScriptManager1"runat="server"></asp:ScriptManager><asp:UpdatePanelid="UpdatePanel1"runat="server"><contenttemplate>

<

asp:Buttonid="Button1"onclick="Button1_Click"runat="server"Text="Start"></asp:Button><asp:Labelid="Label1"runat="server"Text="Label"></asp:Label>

</

contenttemplate><triggers>

<

asp:AsyncPostBackTriggerControlID="Timer1"EventName="Tick"></asp:AsyncPostBackTrigger>

</

triggers></asp:UpdatePanel><asp:Timerid="Timer1"runat="server"Enabled="False"Interval="5000"OnTick="Timer1_Tick"></asp:Timer>

</

asp:Content>

public

partialclassDefault2 : System.Web.UI.Page

{

protectedvoid Page_Load(object sender,EventArgs e)

{

}

protectedvoid Button1_Click(object sender,EventArgs e)

{

Timer1.Enabled =

true;

Label1.Text =

"Timer started";

}

protectedvoid Timer1_Tick(object sender,EventArgs e)

{

Timer1.Enabled =

false;

Label1.Text =

"Timer stopped";

}

}

Hi, I'm back, managed to post the code... as you can see the Page has a MasterPage. ... while this peace of code works in a Page without a MasterPage...with a MasterPage it would start (or seem to be Enabled) but would never Tick. This is a bug for sure.... I'm testing right now with many possibilities but neither would work..

In fact something really weird and shows more that this is a BUG... is that when on debug the Timer is set to Enabled it will start Ticking but not when started from a Button.

bsebo you have to provide an example similar to what I said... thanks but yours is not what I want... bsebo try doing it with a Tick event ;)... your not using the Timer properly.

Thanks! martin


You right, it doesn't work. If you put the Button1 outside of the UpdatePanel1 then it can enable the Timer1. But, if you put it inside of the UpdatePanel1 then it can't. It seems like a bug because when you look at a:

<script type="text/javascript">
<!--
Sys.Application.add_init(function() {
$create(Sys.UI._Timer, {"enabled":false,"interval":5000}, null, null, $get('ctl00$ContentPlaceHolder1$Timer1'));
});
// -->
 enabled is always set to false.

</script>


It doesn't work yes... but are you sure because of that? I tried on a Page without a MasterPage and viewed the source while a Timer1 was enabled... it still showed that it was "enabled":false.

There's sure a bug... I hope some from the ASP team reads this!

I cannot quite get a grasp on what's happening.. why should a MasterPage conflict that much?

Thanks!


Hello so is there any work arounds?... or have to wait for the fix?