Showing posts with label web. Show all posts
Showing posts with label web. Show all posts

Wednesday, March 28, 2012

PostBack is happening even after using Update Panel and Script Manager

Hi,

I have a ASP.NET web application. I have a gridview and using a RowDataBound andRaisePostBackEventevent for getting the GridView details in the controls below like textboxes, dropdown etc. Now i am using Ajax Extensions controls like Update Panel and Script manager to avoid a postback happening when the GridView row is clicked. Even after implementing them postback is happening. Please see the code bits and let me know if i am missing somewhere.

UI

<asp

:ScriptManagerID="ScriptManager1"runat="server"EnablePartialRendering="true"></asp:ScriptManager>

<

asp:UpdatePanelid="UpdatePanel1"runat="server"UpdateMode="Conditional">

<contenttemplate>

<asp:GridViewID="GridView1"runat="server"OnRowDataBound="GridView1_RowDataBound"CssClass="sampletable"AlternatingRowStyle-CssClass="d1"ShowHeader="true"ShowFooter="false"AllowPaging="true"AllowSorting="true"AutoGenerateColumns="false"DataKeyNames="ProjectID"Width="100%"PageSize="5"><Columns>

<asp:BoundFieldVisible="false"HeaderText="Project ID"DataField="ProjectID"SortExpression="ProjectID"/><asp:BoundFieldHeaderText="Project Name"DataField="ProjectName"SortExpression="ProjectName"/><asp:BoundFieldHeaderText="Site Name"DataField="SiteName"SortExpression="SiteName"/></Columns></asp:GridView><asp:LabelID="Label1"runat="server"Text="Label"></asp:Label><asp:TextBoxID="TextBox1"runat="server"></asp:TextBox><asp:ButtonID="Button1"runat="server"Text="Button"/>

</

contenttemplate>

<

Triggers>

<

asp:AsyncPostBackTriggerControlID="GridView1"EventName="RowDataBound"/>

</

Triggers>

</

asp:UpdatePanel>

And theCode behind for RowDatabound event is

protected

void GridView1_RowDataBound(object sender,GridViewRowEventArgs e)

{

try

{

if (!((e.Row.RowType ==DataControlRowType.Pager) || (e.Row.RowType ==DataControlRowType.Header) || (e.Row.RowType ==DataControlRowType.Footer)))

{

System.Web.UI.

ClientScriptManager cs = Page.ClientScript;//Assign Row Index. This row index used in finding the ID of the clicked rowint intRowIndex = e.Row.RowIndex;

e.Row.Attributes.Add(

"onClick", cs.GetPostBackEventReference(this, intRowIndex.ToString().Trim()));

e.Row.Attributes.Add(

"onKeyDown","if( event.keyCode == 13 ) " + cs.GetPostBackEventReference(this,"KEYDOWN" +"$" + e.Row.DataItemIndex.ToString().Trim()));

}

}

catch (System.Exception ex)

{

//OnError(ex);

}

}

The code looks good, did you try a easy test to see if the postback is hidden?

http://alpascual.com/blog/al/archive/2006/12/21/Code-Snip-_2200_AJAX-Timer_2200_.aspx

Try the sample below and let me know if you see the postback


Thanks for the Quick Response.

But i could not get exactly what you want to convey.

regards,

Parimal


Ok, wrap a asp:button around an updatepanel and let me know if you see the postback

Hi,

The button is working fine without any post back. The Post back is happening when Grid Row is clicked as it call the RaisePostBack event to get the Row details. That event is coded as we have not used any command template in Grid.

regards,

Parimal


OnRowDatabound would not make sense for an async trigger. The user clicking the row and getting a postback via the javascript you added to the onclick is not the same. If you take out the trigger and just add ChildrenAsTriggers="true" to the UpdatePanel it would probably work as you expect.

One other thing - in this code:

"onClick", cs.GetPostBackEventReference(this, intRowIndex.ToString().Trim()));

e.Row.Attributes.Add(

"onKeyDown","if( event.keyCode == 13 ) " + cs.GetPostBackEventReference(this,"KEYDOWN" +"$" + e.Row.DataItemIndex.ToString().Trim()));

Change "this" to GridView1. You want to create a postback for your gridview, not the whole page. Since you're creating a custom postback you'll also need to register for event validation, or disable event validation in your page.


Thanks for the response. But still post back is happening. I will explain in details

1. I have a Gridview RowDataBound event which fires when Data is bounded to Grid.

2. I have aRaisePostBackEvent which fires when the row in the Grid is selected and this causes the Post Back event.

3. Aslo my UserControl is implementingIPostBackEventHandler interface.

Thanks in Advance,

Parimal

PostBack once all lists in CascadingDropDown are selected

Has anyone found a way to generate a postback once all lists in a CascadingDropDown have a valid selection.

I am converting a web app that has many places where the user has to select Software, Version, Terrain and Course (It's a Virtual Reality Cycling Portal) Previously each selection caused a postback to populate the next list. On each post back the state of the page may need to changed, in terms of different controls being visible to capture either the riders time or the distance they cover.

I have switched to using Atlas and created a UserControl with the CDD to reduce the postbacks, but I still need to change the state of the controls with a postback, as I need to lookup details of the course to determine which controls should be visible.

So what I need to do is generate a postback once all lists have a valid selection. As a last resort I can turn the Ride Upload tool I am referring to into a wizard, but I would prefer to keep the new UI similar to the original single form one users are already using.

The user control is working great in all but this one scenario, as the other scenarios all require the user to click on a button to trigger the update of a data control.

Once the last CDD gets a selection, you know that all the CDDs have a selection - might you be able to tag the last CDD with AutoPostBack? Alternatively, maybe you could write a little bit of JS to run on the client side and hook the onchange event of the DDL and do the postback manually?

postback problem

i have asp.net web page,on page load i create a simple html table with fixed no of rows and no of columns and their names are determined dynamically.now i have few javascipt functions for adding a row to table,for adding another column to table and for removinga row from table.

also i have a asp:button on click of which a xml file is generated from the data filled in by user in the table.but as soon as i hit the asp button to generate xml all newley added rows and columns are deleated.Is it possible to call a server side function without posting the page back.

Yes, it is

take a look at this article about client scripts callbacks:

http://msdn.microsoft.com/msdnmag/issues/04/08/CuttingEdge/

Cheers,

Yani


hey went throught the article actually i mean new to all this so didnt get it completely some code help from ur side will be appriciated

actually i have a method on server side that accepts the html table parses it and writes the data of html table in a xml file.

and i want to call this method on click of a button and without postback.

thanx in advance

sandeep


Sorry man,

I haven't put the client scripts callbacks into practice yet too.

I was going to use them to create a dynamic progress bar, but then i've decided to use the ajax update panel.

It was much faster and cheaper.

Cheers,

Yani

Povide Drag Option across Datagrids(Drag and Drop)

Thanks in advance for assisting me,

I am developing a asp.net web application(VB.Net).

I am New to AJAX and have a requirement where i should be able to select(say using a check box) and drag(move) a particular or a set of rows from one datagrid to a another datagrid in the same page.

Is this feasible ,what should be the approach......

Hi,

If your using checkbox or any other way to mark the rows you wanted move..... you can either create a xml ....(The data to be moved) or you can create a temp table and you can update the new datagrid... well, I am not quite sure that, through client side code the data can be moved between two datagrid is possible..? May be primary datagrid data can be as XML document though which the secondary data grid can be updated......

Pre Fetching Data - InitialData Control?

Are there any features in ASP.NET AJAX for pre-fetching data? I'm thinking of a feature that would prevent the app from frequently pinging the web server for data (i.e. auto complete, cascading drop down).

From what I can tell, at one point there was an "InitialData" control that was aimed at sending a chunk of data down with the first request. It seems however that this control has been pulled from both Beta2 and the Futures. Does anyone know the status of this control?

Thanks!

Here is a solution for pre-fetching data for your reference.
????At any point in an Ajaxian application's lifetime, the user has the option to perform a number of activities. At the very least, there are always two things the user could do in the next moment: (a) close the application (by quitting the browser or closing the application window/tab); (b) nothing. And of course, there are usually a multitude of application-specific activities that can occur at any time.

Some of these user activities will trigger a remote scripting call to the server before returning for browser-side processing, and the delay will usually be noticeable. That's unfortunate for usability, because responses should ideally feel as if they are instantaneous. The computer not being able to freeze time, the response will never really be instantaneous. But from a usability perspective, it should ideally give that impression. To provide results at a pace that is below the level of human consciousness, a typical guideline is that the application should respond in under 10 milliseconds. That's a hard ask when a trip to the server is required. Especially in a global context, where a trip to the sever and back might cost a second or more due to network overheads.

The obvious motivation for instantaneous feedback is throughput: the user can achieve more because they're not waiting as long for results. Actually, that's not such a major issue: what's a few seconds when you're working on a document for half-an-hour?

Often, the biggest downside of latency is the distraction it causes. The user is focused on a task, and may well be in a state of "flow". A delay will cause a loss of concentration and, in addition to the time it takes to get back to this train of mind, there's also a risk that an idea might be lost forever.

Another problem is simply user frustration. Users generally like to feel in control of a system, so it's not ideal when the system causes delays, especially unpredictable delays.

A final issue with latency is its effect on responsivenes. When users are making decisions in real-time, they need real-time data. For an application such as financial trading, even a consistent 100-millisecond lead can make a big impact on overall performance.

Pre-fetching attempts to remove the delay altogether for certain user actions. It's usually infeasible to pre-fetch results for all actions, so the designer must be judicious in anticipating actions. We are especially interested in actions which are likely to be performed, so that the probability of no response is high. Furthermore, even unlikely actions may also be worth pre-fetching for, if they are critical to the application. Imagine an emergency response system, where the choices are "View your preferences", "Work on reports", and "Dispatch emergency units". The last of these might not occur very often, but which one would you like to be prefetched?

Another downside of pre-fetching is erratic behaviour. A good usability principle is consistent behaviour, but with Predictive Fetch, the user may be surpised that some commands respond instantaneously, while virtually identical commands take a long time. To make the waiting time more comfortable, consider showing a Progress Inidicator.
Advanced Networking Scenarios Not Available in the RTM Release
The following networking features of the CTP release willnot be available in the RTM release:
?The iframe executor. This feature provided support for cross-domain calls, and is not available in RTM release in part because of security concerns.
?The following infrequently used features:
oAssembly-based method calls.
oInitialData control.
oBatching of Web service calls.

Monday, March 26, 2012

Prerequisites to run Ajax Enabled Web sites !

Hey,

Do I need to install the Ajax Framework on the server to launch the Ajax Enabled websites.

Thanks and Regards

RS

You don't need to install AJAX extensions on production server, but you have to make sure that file Microsoft.Web.Extensions.dll included in Bin folder of your web application.

HeyJasonMDLi ,

My Questions is not about the Extensions part but about the Frame work. Do I need to Install the Ajax Framework?


No, you don't. Extension I mentioned is exact AJAX Framework you mentioned. Don't forget copy the file into Bin folder of webapp.
No, you don't. Extension I mentioned is exact AJAX Framework you mentioned. Don't forget to copy the file into Bin folder of webapp.

Hey,

Just make sure to check the .net framework version in iis, everything else is done the same way as before. When you compile your solution, all the files will be in the bin folder as mentionned previously.Smile

print button of Crystal report 11.5 didnt show pop-up dialog with AJAX

I have developed one web application with ASP.Net 2.0 with AJAX 1.0 and Crystal Report 11.5 Release 2.

When i put Crystal Report viewer in AJAX's update panel, Crystal report viewer is opened properly, but when i try to export or print the report from Crystal Report viewer, it is not showing any dialog box for export or print. Print mode of Crystal report viewer is ActiveX.

Can any body help regarding this problem with example(if possible) ?

Regards,

Krunal Shah

http://forums.asp.net/thread/1325110.aspx
(UpdatePanel does not allow the CrystalReportViewer control to print or export.)

http://forums.asp.net/thread/1660467.aspx
(button inside update panel Firefox problem)

etc., etc.

Probelms with Modal Popup via server in code behind

Hi all

I am having problems while adding the modal popup dynamically to my page on the server side on a (web user control). When I set the "TargetControlId" or the "PopupControlId" like this -

ModalPopupExtender modPop = new ModalPopupExtender();
TextBox tbMsg = new TextBox();
tbMsg.ID = "tbMsg";
tbMsg.Text = "Thanks!";
modPop.ID = "modulePopup";
modPop.TargetControlID = hiddenField.ID; //made this hidden field in the user control
modPop.PopupControlID = tbMsg.ClientID;
modPop.BackgroundCssClass = "modalBackground";
modPop.X = 200;
modPop.Y = 200;

Now what is happening is that the ID's that go to the modal popup javascript (ScriptResource etc) I see that it goes in as the name of the textbox itself "tbmsg" instead of the client ID ? so I see something like document.getElementByID("tbMsg") !!!

What am I supposed to do??

Thanks in advance

Sanchita

hiddenField.ClientID will get the ID which is generated by ASP.net

Problem - Adding AJAX ddls as a reference rather than GAC (.msi) install

I have spent a lot of time reading these forums and realize that this is a very hot question right now. I fall into the plethora of people who's web host does not install the AJAX.msi...

After reading for a while I have come across multiple posts that stated that they have simply added the dll's as a reference and got their site running without even having to touch the GAC. Despite this, people still seem to be having troubles (including me) doing this and there also seems to be a bit of a dispute as to teh disadvantages to this approach (especiall the trust factor).

Can someone, who has successfully added these as a refernce and not via the GAC, do a quick walkthrough for the rest of us? I have added them, but cannot get AJAX controls to function (it complies fine without erros, but they do not "activiate" or anything while I am debugging). If someone could do a detailed walkthrough, I think it will not only help many out, but it will also make AJAX avalible to many many other people.

Finally, if anyone can comment on the disadvantages of this, that would be great as well. Hopefully, we can get this all in one place so that everyone will have a nice reference. Thanks!

Nathan

With each version of Atlas and then the most recent releases of Ajax and the Toolkit I did exactly what you are asking about each time, successfully.

There are only two requirements, other than the actual code in your Ajax enabled pages.

1) Your applications /bin/ folder much contain the correct DLLs.

2) Your applications web.config must contain the correct information about the build versions in your apps /bin/ folder.

The easiest way for me to make the changes each time has been to use the sample Ajax web.config provided to modify my own apps web.config


Thanks for the reply!j

I guess my problem is stemming from the web.config then. i am attempting to customize it to fit my build... I know very little about it. To honest, i am not fluent enough to determine which parts are needed specifically. Can you post the changes you made in order to adapt it to "point" to your bin directory? Thanks!


No problem.

This is a working web.config for each of the current versions:

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

<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<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"/>
<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"/>
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false"/>
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false"/>
</sectionGroup>
</sectionGroup>
</sectionGroup>
</configSections>
<connectionStrings>
<clear />
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer" connectionString="Data Source=server;Initial Catalog=database;User ID=user;Password=password;" providerName="System.Data.SqlClient" />
</connectionStrings>
<system.net>
<mailSettings>
<smtp>
<network host="localhost" port="25"/>
</smtp>
</mailSettings>
</system.net>
<system.web>
<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagPrefix="asp" namespace="Microsoft.Web.Preview.UI" assembly="Microsoft.Web.Preview"/>
<add tagPrefix="asp" namespace="Microsoft.Web.Preview.UI.Controls" assembly="Microsoft.Web.Preview"/>
</controls>
<tagMapping>
<add tagType="System.Web.UI.WebControls.CompareValidator" mappedTagType="Sample.Web.UI.Compatibility.CompareValidator, Validators, Version=1.0.0.0"/>
<add tagType="System.Web.UI.WebControls.CustomValidator" mappedTagType="Sample.Web.UI.Compatibility.CustomValidator, Validators, Version=1.0.0.0"/>
<add tagType="System.Web.UI.WebControls.RangeValidator" mappedTagType="Sample.Web.UI.Compatibility.RangeValidator, Validators, Version=1.0.0.0"/>
<add tagType="System.Web.UI.WebControls.RegularExpressionValidator" mappedTagType="Sample.Web.UI.Compatibility.RegularExpressionValidator, Validators, Version=1.0.0.0"/>
<add tagType="System.Web.UI.WebControls.RequiredFieldValidator" mappedTagType="Sample.Web.UI.Compatibility.RequiredFieldValidator, Validators, Version=1.0.0.0"/>
<add tagType="System.Web.UI.WebControls.ValidationSummary" mappedTagType="Sample.Web.UI.Compatibility.ValidationSummary, Validators, Version=1.0.0.0"/>
</tagMapping>
</pages>
<compilation debug="false">
<assemblies>
<add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/></assemblies>
<buildProviders>
<add extension="*.asbx" type="Microsoft.Web.Preview.Services.BridgeBuildProvider"/>
</buildProviders>
</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" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
<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"/>
<add verb="GET,HEAD,POST" path="*.asbx" type="System.Web.Script.Services.ScriptHandlerFactory, 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.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-ISAPI-2.0"/>
<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" verb="GET" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="ASBXHandler" verb="GET,HEAD,POST" path="*.asbx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</handlers>
</system.webServer>
</configuration>
--------------------------


I appreciate the assitance there, but I am still having no luck. I have spoken with a few others who are encoutering the same errors as I am. They stated that this is a trust issue set by my host rather than a configuration issue that I am having...<trust level="Medium"/>

I am at a loss of what else to try other than to hope that my host comes to their senses... Thanks! If you have any other ideas, please let me konw. thanks!


I'd still like to help you overcome this, can you mention the host so some of us might look into this for you?

I've seen reports of some hosts not allowing full trust but still wonder why...

By the way, what happens if you remove the trust level or set it to "full"?


Hey! I really appreciate you will to help me with this! You rock!

Anyway, I host with godaddy.com. What kills me is that their hosting plan is insanely awesome / cheap, but they are lacking in this, :( ... I have called them and asked if they have / were planning to install the AJAX updates. They said that they had no plans to do so.

If I remove the trust level or raise it to full, I get the same error that I was speaking of (I will post it in the next post).

If you would like, I would be more than happy to open up a temp user / pwd on my account and let you tinker with it via ftp, if you would feel comfortable doing so.

Thanks again!


My good ol' error...

Server Error in '/' Application.


Attempt to access the method failed.

Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details:System.MethodAccessException: Attempt to access the method failed.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


I don't deal with godaddy at all but suggest you ask them if an Ajax installation might be an option for you if you use their Metropolis addon.

https://www.godaddy.com/gdshop/hosting/shared.asp?ci=260

You might also want to mention to them that many of the Starter Kits they offer may soon include Ajax, which I'm sure they already know.

I can't suggest any ASP.NET host to match those unbelievably low prices but can suggest a very good host with the works,http://www.DiscountASP.net


I have read that if the trust level is not set to full, then the dlls need to be in the GAC,
or AJAX simply won't work.

This is by design,

Yours
Andreas Knudsen

Okay,

I am goign to speak with Godaddy in the morning. hopefully we can work something out. I appreciate all the feedback. I will post my results. Thanks!


I too have this problem with my host, What are the disadvantages of your host running full trust?

Hi,

Any luck with godaddy? I am also using their hosting and having the same problem. So, to solve a problem I am temporary using Atlas AJAX July build. But it is kind of slow. So, I am planning to switch to another hosting company.


I've done the same thing but I get a different kind of error:

Description:Anerror occurred during the processing of a configuration file requiredto service this request. Please review the specific error details belowand modify your configuration file appropriately.

Parser Error Message:Couldnot load file or assembly 'System.Web.Extensions, Version=1.0.61025.0,Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of itsdependencies. The module was expected to contain an assembly manifest.

Source Error:

Line 45: <assemblies>
Line 46:
Line 47: <add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
Line 48: <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
Line 49: <add assembly="System.Web.Extensions.Design, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

Can someone help me out pls!! Im dying to see my AJAX site in action!


Your assembly information is correct.

Who is the Host? Are they allowing Full trust? (Application's bin folder)

Have you tried placing the Ajax DLLs in your apps /bin/ folder?
(Look for these in: C:\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\v1.0.61025\)

PROBLEM - Timer Control calling Web Service?

Hi,

I have an issue, where I need to utiliize the AJAX Timer Control to continously poll an AJAX Web Service. Now I have successfully been calling the Web Service directly from Javascript, without any issue, however I need to perform some server-side actions.

Hence i need to use the Timer control to perform a onTick event call, which uses the same AJAX Web Service on the server side as follows:

iWebService ws = new iWebService();

string response = ws.iFunction("some data");

The problem here is i recieve the following error on every interval call from the Timer;

Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occured while processing the request on the server. The status code returned from the server was: 500

If anyone can help here, then that would be great, otherwise a temporary solution for my problem is to get the Timer to call a client side function instead of the server side one, and then for me to make a traditional Javascript request to the Web Service. If anyone knows how to do this, I would be very greatful.

Thank you!

We'd need to see some code to figure out what's going on, but rather than using the server Timer control, you're probably better off downloading the Futures January CTP and using the Sys.Preview.Timer control in there.

Hi, Steve

<formid="mainform"runat="server">

<asp:ScriptManagerID="ScriptManager1"runat="server"><Services><asp:ServiceReferencePath="iWebService.asmx"/></Services></asp:ScriptManager><asp:Timerid="timToolBar"runat="server"OnTick="Refresher"Interval="5000"></asp:Timer><asp:UpdatePanelID="upToolBar"runat="server"UpdateMode="Conditional"><Triggers><asp:AsyncPostBackTriggerControlID="timToolBar"/></Triggers><ContentTemplate><uc2:ctrlToolBarID="ToolBar"runat="server"/></ContentTemplate></asp:UpdatePanel>
//CODE BEHIND FILE 

protected void Refresher(object sender, EventArgs e)

{

iMediaService ws =newiMediaService();

string response = ws.GetEvent(sessionid.Value, 2000);

//Some code here to update the Toolbar

}

It's pretty simple to be honest, the call to the WS basically returns some info I use to update the ToolBar. I need to call the WS continuosly, but information is only returned if the iWebService.RegisterClient is called first, before this, the call to GetEvent returns an empty string, which is correct. But after the RegisterClient has been called, i should get some data back from every call to the ws.GetEvent function.

Simple Call Logic

1. Register Client

2. Repeat call to GetEvent & Update ToolBar

The first call to GetEvent after the RegisterClient works fine and i recieve the correct data, but after that, when the Timer fires every interval, i get that error message. The ToolBar is a Web User Control, now simply I could just output the response string from GetEvent to a TextBox for testing, but like i said, the first call is fine, after that it just throws that error.

Also as i was debugging this, the debugger was not breaking on my breakpoint on the first line of the Refresher function, i think theres a problem after i write some info to the ToolBar.


The 500 suggests that something's breaking on the server. I would recommend grabbingNikhil's Web Development Helper and taking a look at the request and 500 response. It's quite likely the contents of the response will show you exactly what the problem is.

(As it is, I can't really guess what's going wrong.)

Problem about area of focus

Hello frnds,

I have created Web application using AJAX control tool kit......you may view it here......

www.calstate.edu/majors


My problem here is that If I select 1 item from DropDownList(DDL) 1 and then choose DDL2 and then press search button; everything works fine.....

But now If I select other item from DDL1 again, so I want the DDL2 to be set to default value as Before ie. I want it to be to Select Major Type/Degree....so what shud be added in order to change the default value of DDL2 back to original.


Thanks ur help is highly appreciated

Hemil.

write a event for DDL1's selectedindexchanged and set the ddl2's selectedindex to 0.

And also mark enableautopostback to true for ddl1


hi,

After seen the site I think the problem is that the selected value of second DDL is remain as it is so after the search result of in the selected index chnage event of first DDL just make the SelectedValue to default means index to 0 every time then it will be work


I tried changing the same, but When I write the line in the function

protected void majorDDL_SelectedIndexChanged(object sender, EventArgs e)

it says cannot assign to majorDDL_SelectedIndexChanged becoz it is a method grp.......so where shud I write the value 0....


Could you please share your code?


C-sharp file

protected void majorDDL_SelectedIndexChanged(object sender, EventArgs e)
{
visibleOff();
searchButton.Enabled = false;

}

.aspx file

<ajaxToolkit:ToolkitScriptManager ID="ScriptManager1" runat="server" /
<label for="majorDDL" style="display:none;">Select Programs Name and Type:</label><asp:DropDownList ID="majorDDL" runat="server"
OnSelectedIndexChanged="majorDDL_SelectedIndexChanged"
AutoPostBack="True">
</asp:DropDownList
<ajaxToolkit:CascadingDropDown ID="CascadingDropDown1" runat="server"
ServiceMethod="GetDropDownContents"
UseContextKey="True"
Category="major"
LoadingText="..."
PromptText="Degree Major/ Program Name"
ServicePath="MajorsDatabase.asmx"
TargetControlID="majorDDL">
</ajaxToolkit:CascadingDropDown>
<br /><br />
<label for="typeDDL" style="display:none;">Select Programs Name and Type:</label>
<asp:DropDownList ID="typeDDL" runat="server"
OnSelectedIndexChanged="typeDDL_SelectedIndexChanged" AutoPostBack="True">
</asp:DropDownList>

<ajaxToolkit:CascadingDropDown ID="CascadingDropDown2" runat="server"
ParentControlID="majorDDL"
Category="type"
ContextKey="..."
PromptText="Degree Major/ Program Type"
ServiceMethod="GetDropDownContents"
ServicePath="MajorsDatabase.asmx"
TargetControlID="typeDDL">
</ajaxToolkit:CascadingDropDown


I want to make DROPDOWN 2 value to default ie it shud display the value of PromptText="Degree Major/ Program Type".......


I suppose this is automatically handle by extender

http://asp.net/ajax/ajaxcontroltoolkit/samples/

Saturday, March 24, 2012

Problem accessing the Items with a Cascading dropdown

I got a web page, inside there is a userControl with two cascading dropdown list, and i got a grid as well (it isn't inside the usercontrol). The cascading ddl are working fine, they get populated and everything, my problem is when I try to load a record from de grid I have to check if this record is inside the second cascading ddl (if it has been populated), and I cannot see the items inside my second cascading ddl (neither the normal ddl) so I cannot check if the record exists, Does anyone know how to tackle this? as well I presume that I will have problems trying to set the selected value once I've been able to check if it exists or not, Any ideas??

Thanks very much!!!!!!!

Hi,

I fail to reproduce the issue. Can you show me your code?

Problem adding atlas controls to existing web form

I created an atlas web site from the Atlas Template and added some files from another web site, so I tried to add <atlas:ScriptManager...> tag, but VS2005 didn't recognize Atlas (now ASP.Net AJAX) tags.

How can I add Atlas to existing ASP.Net web sites?

i'll need to register the "altas" tag in your web.config file.

I've discovered the problem. Atlas intellisense doesn't work in projects on network shares, so I installed Visual Source Safe and now it recognizes as being run locally.

Problem adding toolkit to the web.config on my server

I am trying to add the toolkit to my server's web.config so that I do not have to register the toolkit on each page that I use the extenders on. I have added the following config items but am receiving the error listed below when I attempt to use a control. Is there an issue with using the extenders on master pages? Everything works fine from a VWD perspective, intellisense picks up the toolkit controls just fine. The error only occurs on the server. Any help would be greatly apprectiately.

I have added the following to the <compilation><assemblies> section:

<add assembly="AjaxControlToolkit, Version=1.0.10618.0, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"/>

I have also added the following within the <system.web> section:

<pages>
<controls>
<add namespace="AjaxControlToolkit" assembly="AjaxControlToolkit" tagPrefix="ajaxToolkit" />
</controls>
</pages>

Error text:


Parser Error

Description:An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message:Unknown server tag 'ajaxToolkit:TextBoxWatermarkExtender'.

Source Error:

Line 48: ErrorMessage="User Name is required." Display="dynamic" ToolTip="User Name is required." ValidationGroup="ctl00$ctl00$Login1">*</asp:RequiredFieldValidator>Line 49:Line 50: <ajaxToolkit:TextBoxWatermarkExtender id="wm1" runat="server" TargetControlID="UserName" WatermarkText="Username" />Line 51: </td>Line 52: </tr>

The problem turned out to be an issue with the AJAX Extension configuration in the web.config. To fix it I just copied the info from the web.config from the Extensions install directory.


I am trying to do this right now too. Could you provide a little more detail about your fix? Where is the Extensions install directory? And what info did you copy from the web.config?

Also, how do I determine what the proper assembly info to use (i.e. version# and public key token...)

Thanks!


The path for the Extensions install directory on my dev machine is:

C:\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\v1.0.61025

That should be the default path for the AJAX Extensions installer.

Located in that folder should be a web.config file. All of the info in there needs to be copied into the web.config for your app. You'll have to make sure you aren't duplicating sections if you just paste the whole bit in your config. Posted below is a direct copy of the web.config for your convenience.

As for the issue of knowing which version and public token, I just take those from the samples. In the case of the Extensions, the config below lists the correct info and you shouldn't have to change it. For the case of the toolkit, the version will be the same as the release you are currently using. As for the public token, I'm not entirely sure about that as I have not updated my toolkit to the newest release. If you figure that out post back here to have it documented. (I'll do the same when I upgrade)

I hope this helps solve your issue.

<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="false"> <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>

Problem after upgrading from November 06 release to January 07 release.

I have a web site that was working beautifully with the November 06 release. I then upgraded to the January 07 release, and for the most part, everything is working as expected, with 1 exception.

I have a custom composite control which is basically a custom gridview that has a textbox column added at the end. The TextBox has a MaskedEditExtender. Both the TextBox and MaskedEditExtender are within an UpdatePanel. The GridView is also in an UpdatePanel. The idea is to have the GridView do paging via AJAX, and the TextBox update a shopping cart control with quantity without refreshing the whole GridView. The shopping cart is also contained in an UpdatePanel to reflect the new item added without a refresh.

First time the page loads, everything works correctly. If I then go to a different page of data, then enter a quantity in the textbox column for an item, I get the following javascript error:

Sys.InvalidOperationException: Handler was not added through the Sys.UI.DomEvent.addHandler method

I have confirmed that the TextBox's TextChanged event is indeed getting fired, but it dies with the above error at some point after that.

I am at a complete loss as to how to track down this problem. I would post my code, but there are several hundred lines of it for both the control and the page, and I didn't think it would be a good idea to try.

I would REALLY appreciate any help or suggestions on how to fix this, or at least, locate the source of the problem.

Thanks,

Alex

Just some additional info. As a test, I set EnablePartialRendering = "false" for my ScriptManager, and the site works properly without errors (but, of course, it now does a full postback).

Problem based on following "Scotts todo list" guidelines

Hello

Since I started using ajax I based all my web programming on "Scott's todo list" Video.

That means everything I do is AJAX, CSS and most important of all, ObjectDataSource based. Everything went fine until I decide to use great amounts of data. For example I have now a single table on sql 2005 database with a couple of indexes, the table have more tha 4 million records and growing up, the database runs on a 2 x dual xeon processors, 4GB ram and 10.000 rpm seagate scsi hdd. (I described the machine just for you understand that the problem i'm going to talk is not a preformance problem)

Tha HDD keeps unfragmeted the most of time. But there are much information and the query I did takes more than 30 seconds (I want to call the attention that my query really needs to take more than 30seconds, that's a fact and no matter why). To understand this, when I execute the query the CPU load not pass from 5% to 8%. So I think it is because no matter how fast the hdd is, it is slow to return the data.

From time to time, the user changes parameters in the web page, like incremeting the data range, include specific record types or specific clients, vendors and so incrementing the amount of records to be returned

When it is needed to return much rows, (it is unspecifically the amount of records to be returned,) it takes more than 30 seconds. so from time to time I get the "The timeout period elapsed prior to completion of the operation" error and just at 30 seconds the query stops and I have no results.

Looking for a solution on the internet I conclude the following:

1. It is a very very common error in web sites using .aspx

2. In my case, I do not know others, I use OBJECTDATASOURCE, as indicated on Scott's ToDo List, (where I CAN NOT define a timeout parameter for the database connection), instead of SQLDATASOURCE (where one can define a CommandTimeout parameter)

So How can I extend the TimeOut parameter when I use ObjectDataSource?

As explained above, I do not want answers like, "you need to improve your sql database, make tunning, or such common answers". What I really want to know is HOW TO CHANGE THE TIMEOUT parameter for the ObjectDataSource. That's all. Because there are times when you need to execute systems procedures using for example xp_shell, or whatever that makes your query take more than 30 seconds.

It is possible, Or I need to switch to SqlDataSource?

By the way I changed the timeout value on the web.config at the connection string, but no matter which value I put it always stops at 30 seconds.

Helcjo

Firstly, I'm surprised that you are taking 30+ seconds to run a query!! I know you said you don't want answers like this... and I'm sorry.. but... this sounds huge to me! There have GOT to be ways to reduce this time down.

Secondly, on to what you really want to know... how to set the timeout. Well... you're using an objectdatasource... which simply calls whatever method you specify to return your results. So it sounds like that method must create a SqlConnection then a SqlCommand and execute something. Can you not change the way that this connection behaves so as not to timeout so quickly?


Hello

I guess you will understand better my problem if you see and follow the steps indicated in "SCOTT'S TODO LIST" sample. As you can see, he just drag and drop the objectdatasource to the web page and connects it to the dataset he previously added to the project.

Now imagine millions of records in his sample, in only one table, but with more fields than the Scott's sample.

For your understanding, on why can take more than 30secs a query to be returned, imagine using xp_cmdshell to perform several tasks that take some minutes to be completed. So not necesarily you need to expect for data records from your database.

I'm not sure about what you are saying in the phrase: "Can you not change the way that this connection behaves so as not to timeout so quickly?", could you please explain me


Hello

I mentioned on my post, that after some research on the internet, I found this was a very common problem for aspx. web pages, and if anyone of you try to look in google, yahoo, msn search, etc. then search this error message

"The timeout period elapsed prior to completion of the operation"

, so you will find several amounts of websites with this error. I guess there are several databases which takes more than 30 secs to respond.


Hello Again

I still have exactly the same problem. Just to be known, I used SQL Express 2005 and after no help on this subject, I tried MySQL, added several indexes for the table, just doing what you indicate: looking on how to improve the query, even more added 8GB to the dual xeon machine, but nothing, that's a fact all the queries run much faster, but not yet to outperform the 30secs barrier.

Of course not all the queries take more than 30 secs. So I'm going to ilustrate my problem using real queries:

For example:

select ip, sum(cltbytes), sum(srvbytes), count(*) from log WHERE ip like '192%' and date >= '20070901' and date <= '20070901'' GROUP BY IP, ORDER BY IP

this real simple query which represents only ONE day data, takes no more than 2 secs resulting from almost 1 million records in just like 50 rows (50 different ips)

As you can see my table have only 5 columns: ip varchar(16), date datetime, cltbytes int, srvbytes int, host varchar(72) and I have an index by IP and other by date

I can not imagine how to make more indexes in order to improve the results, also I can noit imagine how to make a better query that he above one.

The problem starts when I increase the date range, for example:

select ip, sum(cltbytes), sum(srvbytes), count(*) from log WHERE ip like '192%' and date >= '20070901' and date <= '20070916'' GROUP BY IP, ORDER BY IP

as you can see it should obtain data from 15 days, as we can get a sum from almost 15 million records, this query takes more than 25 seconds, but still works because is under the 30 secs barrier.

Of course to get the results for more than 16 days It'S IMPOSSIBLE.

Why it takes more than 30 secs, in two diffrerent databases, ms-sql express 2005 and mysql, I do not know, but I have some idea: The server's HARD DISK can not handle so much data in a more eficient way if you are saving almost a million records per day, Of course I have a fast and powerful hdd a seagate cheetah 73GB 15000 RPM using SCSI 320 , if you know more fastest HDDs I would like to know them.

I would like to see you trying such table in you machine with just 15 million records and running the above query in order to know if the problems is my machine, or my vs2005 or my iis6 or my win 2003. in fact exactly the same problem happens in my develpment machine and in the production server.

A week ago I found wht seems the solution to my problem, an article from your website:http://www.asp.net/learn/data-access/tutorial-72-cs.aspx I followed the instructions, and yes, finally some light at the end of the tunnel, I can now change the CommandTimeOut, BUT it doesn't work with the simple Scott's ToDo List Example.

In order to make it work, I need to manually programmatically type the code, but I do not want to do that. I REALLY WANT THE SCOTT'S TODO sample working with my table. But now, at last, I know where the problem is. the problem is at the autogenerated code for the dataset when adding datasets at the app_code folder in my application.

So, I have now another idea, how can I hack vs2005 in order to change the default timeout value of 30 seconds when it generates on the fly code for the DATASET? and why somebody at microsft decided that 30 secs is enough for all the cases instead of leaving it forever or at least let the user pass the parameter when issuing the databind() for the ObjectDataSource?

thanks

Helcjo

Problem binding DataTable to ListView using "set_data(result)"

Hello,

I'm calling a web service which is providing a DataTable to my client ASP.NET AJAX javascript code. I'm then trying to bind that data table to a client listview control. The code runs without error message but no results are displayed, despite the datatable having positive content. The problem seems to arise because the "set_data" makes a call to "render" and in that method it checks the validity of "get_length", which the client DataTable does NOT support, so the code falls out to the "Empty Data" template. Basically it seems that ASP.NET AJAX is not expecting to see a DataTable at all, but something else. Can anyone help me with this please?

Here is my page code, the WebService.asmx simply returns a DataTable and "main()" simply wires up the button to kick the process off. the commented code will successfully display the data as an unordered list (simulating a listview):

<%@dotnet.itags.org. Page Language="C#" AutoEventWireup="true" CodeFile="ListViewUnorderedList.aspx.cs" Inherits="ListViewUnorderedList" %>

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

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script>
function main()
{
document.getElementById("btnLoadVendors").onclick = getVendors;
}

function getVendors()
{
var onVendors = function(result)
{

// result is a dataset or data object
var ele = document.getElementById("output");
var ctl = ele.control;
ctl.set_data(result);

/* This would work and do the same job...
ele.innerHTML = "<ul>";
for (var i=0; i<result.rows.length; i++)
{
ele.innerHTML += "<li>" + result.rows[i].Name + "</li>";

}
ele.innerHTML += "</ul>";
*/
}
WebService.getVendors(onVendors);
}

</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Scripts>
<asp:ScriptReference Assembly="Microsoft.Web.Preview" Name="PreviewScript.js" />
<asp:ScriptReference Assembly="Microsoft.Web.Preview" Name="PreviewGlitz.js" />
<asp:ScriptReference Assembly="Microsoft.Web.Preview" Name="PreviewDragDrop.js" />
</Scripts>
<Services>
<asp:ServiceReference Path="WebService.asmx" />
</Services>
</asp:ScriptManager>
<script>
Sys.Application.get_events().addHandler("load", main);
</script>
<input id="btnLoadVendors" type="button" value="Load Vendors" />
<!-- Template for output -->
<div id="output">
Vendor list goes here.
<div style="display:none">
<div id="vendorsLayout">
<ul id="vendorsItemParent">
<li id="vendorsItem">
<span id="vendorsName">Vendor Name goes here</span>
</li>
</ul>
</div>
</div>
</div>
</form>



<script type="text/xml-script">
<page xmlns="http://schemas.microsoft.com/xml-script/2005">
<components>
<listView itemTemplateParentElementId="vendorsItemParent" id="output">

<layoutTemplate>
<template layoutElement="vendorsLayout" />
</layoutTemplate>

<itemTemplate>
<template layoutElement="vendorsItem">
<label id="vendorsName">
<bindings>
<binding dataPath="Name" property="text" transform="ToString" />
</bindings>
</label>
</template>
</itemTemplate>

</listView>
</components>
</page>
</script>
</body>
</html>

bump

With hindsight, perhaps I've worded this problem all wrong.

Basically, the "set_data" method of a client control does not accept/understand an ASP.NET AJAX Client datatable object, as I was led to believe it did.

So what object structure do you pass to it?


Well, it looks as if the answer is to pass it the "rows" property of a datatable, this seems to work:

document.getElementById(

"output").control.set_data(result.rows);

Problem calling Web Service using the DynamicPopulate Extender - Web Service Call Fails: 5

Hi, I'm quite new to ASP.Net AJAX so please forgive my ignorance.

I have downloaded and installed the RC1 version and am following through some of the tutorial videos.

I am having a problem with the Dynamic Populate Extender example. I have created some asp controls with onclick events calling a javascript function. From there I am attempting to use a dynamic populate extender control to call a web service - it's a function declared on that ASPX page as the tutorial explains in necessary and decorated with the System.Web.Services.WebMEthod AND System.Web.Script.Services.ScriptMethod attributes.

Everything works as expected until I attempt to pass a parameter to the web services - in fact until I declare the web service function with a parameter. Once I do this, all that is returned to (or at least all that displays in) the control linked to the DynamicPopulateExtender is "Web Service Call Failed: 500".

Can anyone possibly put me on the right track here? (or would I need to post some code examples?)

Thanks in Advance.

Stu.

the tutorial is in beta version.

i will post my code for you

ASPX page

<%@. Page Language="C#" AutoEventWireup="true" Codebehind="Default.aspx.cs" Inherits="DynamicPopulateDemo._Default" %>

<%@. 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">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>

</head>
<body>

<form id="form1" runat="server">
<script type="text/javascript">

function updateDateKey(value) {

var behavior = $find('dpe');

if (behavior) {
behavior.populate(value);
}

}

Sys.Application.add_load(function(){updateDateKey('G');});
</script>

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<cc1:DynamicPopulateExtender ID="dpe" runat="server" ClearContentsDuringUpdate="true"
PopulateTriggerControlID="Label1" TargetControlID="pan" ServiceMethod="GetHtml">
</cc1:DynamicPopulateExtender>

<p>
<asp:Label ID="Label1" runat="server" Text="Label" CssClass="subheading">Time at the server:</asp:Label>
</p>
Choose a date/time format:<p>
<label for="r0"><input type="radio" name="rbFormat" id="Radio1" value='G' onclick="updateDateKey(this.value);" checked="checked" />Normal</label><br />
<label for="r1"><input type="radio" name="rbFormat" id="Radio2" value='d' onclick="updateDateKey(this.value);" />Short Date</label><br />
<label for="r2"><input type="radio" name="rbFormat" id="Radio3" value='D' onclick="updateDateKey(this.value);" />Long Date</label><br />
<label for="r3"><input type="radio" name="rbFormat" id="Radio4" value='U' onclick="updateDateKey(this.value);" />UTC Date/Time</label><br />
</p>
<br />
<p>

This time is dynamically formatted and<br /> returned as HTML from the server:

<asp:Panel ID="pan" runat="server" BorderColor="#404040" BorderStyle="Solid" BorderWidth="1px" Height="15px" HorizontalAlign="Center" Width="380px">
</asp:Panel>
</p>

</form>


</body>

</html>

ASPX.CS

using System;
using System.Data;
using System.Configuration;
using System.Collections;
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;

namespace DynamicPopulateDemo
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
[System.Web.Script.Services.ScriptMethod]
[System.Web.Services.WebMethod()]
public static string GetHtml(string contextKey)
{
System.Threading.Thread.Sleep(250);
string value = string.Empty;

if (contextKey == "U")
{
value = DateTime.UtcNow.ToString();
}
else
{
value = String.Format("{0:" + contextKey + "}", DateTime.Now);
}
return String.Format("<span style='font-family:courier new;font-weight:bold;'>{0}</span>", value);


}
}
}


Thankyou very much for posting this code.

I have worked through the differences between your version of the tutorial and the code I was trying to get running. It all boiled down to the name of the parameter on the web service method. I don't understand this yet but if I call the parameter on my web service method, "contextKey" it works, if I call it anything else, it fails.

Is anyone able to shed some light on this for me?


In the documentation it states that the paramater must be astring namedcontextKey

[WebMethod]string DynamicPopulateMethod(string contextKey) { ... }

Note you can replace "DynamicPopulateMethod" with a naming of your choice, but thereturn type and parameter name and type must exactly match, including case.

Problem forcing an UpdatePanel to post from client-side code (javascript)...

Here's what I'm trying to achieve. I have a rather complex web page that allows data entry. The page utilizes Atlas UpdatePanels for partial reposts. When the user clicks on certain buttons, the data is validated (server-side), and then the user is given the option to save or abandon the changes. To do this, I use RegisterJavaScript to insert a client-side call to a javascript function which calls a vbscript function to display a msgbox (we're only using IE). The vbscript function returns the msgbox value back to the javascript function which then sets an ASP HiddenField. The next step is where I'm having problems. I need the javascript function to force a partial postback so that the server-side code can evaluate the msgbox results (in the hidden field), and respond accordingly. I don't want to repost the entire form because I loose data from other asynchronous client-side page modifications.

So the real question is; how can I force an UpdatePanel to post from client-side code? I've read a number of other threads on this subject and a suggested solution is to call the click event of a hidden LinkButton within the UpdatePanel. So I tried this and it worked! At least it worked for a while. This is the most frustrating part. At some point, and I have no idea what changed to cause this, the code stopped working. Now, when I call the click event, I get an undefined error in the doPostBack function and the form will no long post at all.

If anyone has any suggestions on what is causing this problem, or a better way to force an UpdatePanel to partial post, it would be greatly appreciated!

Here's some of my code;

<atlas:UpdatePanel ID="upConfirmActivitySave" runat="server" Mode="conditional"><ContentTemplate> <asp:HiddenField ID="hfConfirmActivitySave" runat="server" /> <asp:LinkButton ID="lnkDoPostBack" runat="server" style="display:none"></asp:LinkButton></ContentTemplate></atlas:UpdatePanel><script language="javascript" type="text/javascript"><!--function confirmActivitySave() { document.getElementById('hfConfirmActivitySave').value = ConfirmActivitySaveMsgbox(); document.getElementById('lnkDoPostBack').click();} // --></script><script language="vbscript" type="text/vbscript"><!--Function ConfirmActivitySaveMsgbox()'This only works for IEConfirmActivitySaveMsgbox = MsgBox("Do you wish to save?",35)End Function// --></script>

I decided to simplify things and created a new aspx page with a single UpdatePanel and two ASP ImageButtons, one inside the UpdatePanel and the other outside the UpdatePanel. The client-side code for the button outside the UP calls the click method for the button inside the UP. And sure enough, I get a partial post. So this tells me there's something wrong with my main project page. I wonder if I've hit some sort of atlas bug or limitation?


This just gets weirder and weirder. I restored my project to a prior version – one that the partial post code still worked. I compared the differences in the html between the working and non working versions and the only changes were some controls that were renamed (all within UpdatePanels) and a single control (an asp:HyperLink) that moved from outside to inside an UpdatePanel. So, from the working code, I moved the one control (using cut/past) and sure enough the page fails during the client-side partial post; "unknown runtime error". And get this; if I delete the control, the page still fails. By the way, all references to this control (client-side and server-side) have been removed. Essentially, the control is unused. But if I delete it, the page fails. What gives? I can remove other controls, or add and remove controls with no problem. It's almost like there's some reference that's not getting deleted correctly. Any ideas? Anyone?

Problem getting AJAX work on content page

Hi,

I want AJAX - enable existing content ASP .NET page. After updating web.config all seemed OK. But ...

I'm still getting full postback even on this simple testing page:

<asp:Content ID="Content1" ContentPlaceHolderID="cphMain" runat="server">
<asp:UpdatePanel ID="upd1" runat="server">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" Text="Button" /><br />
<asp:Label ID="Label1" runat="server" Text="Label"><%# DateTime.Now.ToString()%></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>

As you guess ScriptManager is on master page and I left its properties default.

Any idea what am I missing?

You are missing your triggers!!!!

<triggers>

<asp:AsyncPostBackTrigger controlID="NameofYouControl" EventName="NameofEventThat triggers refresh"> </<asp:AsyncPostBackTrigger>

</triggers>


You are missing your triggers!!!!

<triggers>

<asp:AsyncPostBackTrigger controlID="NameofYouControl" EventName="NameofEventThat triggers refresh"> </<asp:AsyncPostBackTrigger>

</triggers>


<triggers></triggers> goes after <ContentTemplate></ContentTemplate>


Triggers shouldn't be needed in that example... There must be something wrong with the web.config, other code on the page, or possibly a configuration issue in IIS.


i would say it's the web.config issue.