Wednesday, March 28, 2012

Asp.net Ajax Toolkit

Hi, i'musing Ajax 'DynamicPopulateExtender' to show the search results on my page. This is working fine when the search has results. errors 'Web service call failed : 500' when no results found. Can someone help me out?

Hi,

According to your description, this is quite probably caused by your code in the web service. It would be easier to solve it if you debug through the web method since we don't have any idea how your code goes.


Thanks. This is occuring bcz of unhandled exception in the webservice code.

ASP.NET Ajax Timer

Greetings,

i want to implement ajax timer so it will update an updatepanel every five seconds based on a certain codition so i try the following:

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

</div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
<asp:Timer ID="Timer1" runat="server" Interval="5000" OnTick="UpdateTime">
</asp:Timer>

in the code behind i write the folowing:

protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = DateTime.Now.ToLongTimeString();

}
protected void UpdateTime(object sender, EventArgs e)
{
if (new Random().Next(0, 4) == 1)
{
UpdatePanel1.Update();
}

}

so what i notice that every five seconds the tick event will happen and the updatepanel1 will be updated regardless of the condition that i implement it in the UpdateTime method ,what is logic since the tick event happens.

so how can i solve this problem??

your help is highly appreciated

best regards

I tested your codes in Visual Studio .Net 2005 with Ajax RC 1.0.Try to change some of your codes as the following and it should work fine.
<div>
<asp:UpdatePanel ID="upnlTimer" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="lblTimer" runat="server" Text="Date Time"></asp:Label>
<asp:Timer ID="Timer1" runat="server" Interval="5000" OnTick="Timer1_Tick">
</asp:Timer>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
</asp:UpdatePanel>
</div>
Wish the above can help you.

Thank you for the support

so what i add only the

<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server"ChildrenAsTriggers="false" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:Timer ID="Timer1" runat="server" Interval="1000" OnTick="UpdateTime"></asp:Timer>
</ContentTemplate>

</asp:UpdatePanel>
</div>

so when i place the timer control within the contenttemplate of the updatepanel so i dont need to put the timer control within the triggers of the updatepanel

so what i conclude that it will not work if i place the timer control outside the update panel.

ASP.net AJAX throws errors in some browsers

These browsers are:

Mozilla (latest version)
Seamonkey (latest version)
Netscape (latest version)

See this error message:

AJAX error in diverse browsers

Has anyone encountered the same problems in the mentioned browsers? I couldn't check Mac browsers, any known issues in Mac browsers would be interesting too.
Any other browsers that don't like the asp.net AJAX?

This is normallly because you modify the response by using Response.write.Make sure you use a Literal control instead of using response.write.

Mac browsers will have the same error.

It's also possible that the error is caused by Tracing where the pageoutput is set to true. You must set that to false.
<traceenabled="true"requestLimit="128"pageOutput="false"traceMode="SortByTime"localOnly="false"/>


Hi Richard,

thanks for your reply. So I may not use <%= WhateverString %> neither, right? I can't use Response.Write in my code behind files and neither in the "HTML" source code, is that what you are saying?

Steve


Hi Steve,

Yes that is what I meand. I hope it helped you.


To be clear, <%= is just an alias for Response.Write; so there's no differnece at all once it compiels. If it helps, you *can* use Response.Write, just not inside an UpdatePanel, nor as part of any code that will be subject to responding to an update panel's asynch postback.

Asp.net ajax support SSL?

Hey, I released a ajax-based project on live server recently, everythings is fine. (Asp.net ajax v1.0)

But when I turn on the SSL tunnels on app's virtual directory, Ajax doesn't work any more.

for example, a GridView paging functionality within a UpdatePanel, after a long-time loading, it throws timeout exception at client side. (same func works fine under non-SSL).

Can someone give me a tips about how to make Ajax work under SSL? All reply is appreciate!

helo.

are you mixing http with https on the same site or is everything running in https? btw, can you put the stack trace here?


code is very very simple, just GridView paging func under UpdatePanel.

only popup a alert window. here is the screenshot.

Error screentshot


hello again.

hum, can you use fiddler to see what is being send to the server?

ASP.NET AJAX Showcase image rollover ?

I was wondering if anyone knew how the image roll-over was accomplished on the ASP.NET AJAX Showcase page?

http://ajax.asp.net/showcase/default.aspx?tabid=47

Thanks

http://forums.asp.net/1671436/ShowThread.aspx

Prior to making your own post, I recommend searching the forum for existing posts which may answer your question. Smile

ASP.NET AJAX scripts weight

Hi, I'm working with a extremely high bandwidth sensible servers (more than a million pages views per day) and I want to know about the convenience of working with ASP.NET AJAX.


I've seen that everypage with ASP.NET AJAX downloads a JS file (webresource) of more than 80Kb (compressed)... and 80Kb x 1.000.000 = 80 Gb/day...


On the other hand, I know that the user experience is improved, but... what about the server performance?

I only want to know your experiencies on this way: bandwith and server performance with high charge servers.

Well, it's actually 3 files, totalling 134,473 KB, though I checked it w/o GZIP turned on, so I'm not sure how much you gain with it; one of the three doesn't have the whitespace, etc removed already. For argument's sake and round numbers, let's call it 100KB / page.

So, to your point, that's x 1,000,000 so you're looking at 100 GB/day. IF every one of those page loads is a unique user.

Don't forget, if a user navigates within your site, or has been to your site before, their browser should cache those js files and therefore they'd only get hit with that download the first time they come to your site or if they've cleared their cache.

Further, not only is user experience improved, but take a basic webform as an example. If you have a 8 KB page with a form on it, and the user submits said form, then on a normal postback the whole page is served again (all 8KB). If you wrap that form in an updatepanel, then only the form itself is served in response (probably something around 10% of the total page's markup, etc, once you strip out headers, script tags, other sections of the page, and so on). If you forego the updatepanel and write custom js that hits webservices and so on instead, you can potentially reduce it even further (having the web service respond with just the "Everything's great!" message, for example).

I've honestly not done an impact analysis on many small requests, vs. few big ones, so that's an open item for you to investigate, but from a bandwidth perspective, I think you're overall in better shape, unless you have a lot of visitors that are 'first time' visitors from the .js file download perspective.

ASP.NET AJAX ScriptManager

Hi,

I am a total newbee to whole AJAX as well as Javascripting in general. I just installed the ASP.NET AJAX Extensions and Toolkit and I was watching couple of videos on this site. The first video mentioned something about only having 1 instance of the ScriptManager..?

This is how we develop at the moment. We have a general page on which we just drop ASCX (User controls). Each control has thus it's own Load event and all along with it's own design with few controls in it.

So where do I need to drop this ScriptManager control? On every ASCX file?

Cheers,

Nirav Patel

Nirav,

If you have a MasterPage in your website, and you'll be using AJAX on every page then the MasterPage is theonly place where you would drop the ScriptManager control.

Otherwise, you would drop the ScriptManager control to your "general".aspx page.

Let me know if you need more info.


Thanks for a quick reply.

We don't have a master page type of setup nor we have a general page.

What we have is a template where we define section of the page like "header", "content" (this might have "left" for menu, "middle" for contect, "right" for ads), "footer". Then ASCX are inserted into those sections as required.

So can I just modify the template and add the ScriptManager at the top?

Cheers :)


niravpatel:

This is how we develop at the moment. We have ageneral page on which we just drop ASCX (User controls).

The term 'general page' I used because you used it in your original post.

The fact is that there can only be one instance of ScriptManager control per page. This is why you must place the ScriptManager control in a parent .aspx page. If the user controls need to reference a script or a service, then you can use ScriptManagerProxy control in your .ascx controls.


Hiniravpatel,

You should add it after the <form> tag.

<html>
<headrunat="server">
<title></title>
</head>
<body>
<formid="form1"runat="server">
<asp:ScriptManagerID="ScriptManager1"runat="server"></asp:ScriptManager>
</form>
</body>
</html>

Otherwise you will get the following error:

Server Error in '/' Application.
------------------------

Control 'ScriptManager1' of type 'ScriptManager' must be placed inside a form tag with runat=server.

Cheers,
Al