Showing posts with label created. Show all posts
Showing posts with label created. Show all posts

Wednesday, March 28, 2012

Why slow UI with AJAX?

I am working on a page that displays paged ResultSet from a database. I created the page without AJAX update panels. Later I added those to ajaxify my application. The problem is when I change pages in my GridView the time it takes for it show the new results (using Asynchronous postback) is about 4 secs more then a regular postback.

Does any one know why it is slow. I usedfiddler tool to check the response size and Asynchronous postback does come back with less number of bytes but why slow UI update?

Thanks for your help.

The thing that will effect your AJAX postback the greatest is the size of your ViewState.

Comment out your update panels & script manager and then enable tracing for your page.<% @.Page Trace="True" %>The trace information will show you exactly how large your ViewState is for that page. Try paging through your GridView and see if you ViewState size grows as you page. Even if the size doesn't grow, if the initial ViewState size for your page is very large, it will cause long delays between AJAX postbacks. If you do find that your ViewState is huge, or it grows between postbacks, try to figure out which controls you can disable the ViewState for (EnableViewState="False") or what might be causing your ViewState bloat.

Just as an FYI, I have used UpdatePanels with GridViews in many different cases without a problem. I did have to tune the ViewState for some of the pages I made to speed things up, but it can definitely be done and it works great.

-Aaron


I am totally agree withSchnieds , that you have to disable the viewstate wherever it is not necessary..

Do one more thig also..try to set <compilation debug = "false" > in web.config

Hope it will help you.Smile


Thanks for your replies. I tried to turn the viewstate off for the gridview but then my pagging gets all screwed up. I have a dynamic paging option where user can select the number of results displayed per page. When I turn off the viewState it gets set to the default value (which is 14) and the page index gets set to 1.

Any ideas?

P.S.: I do have the <compilation debug="false" />


You probably won't be able to disable the ViewState for your GridView, but you may be able to disable it for other controls on your page and decrease the overall ViewState size.

Turn on tracing as I suggested, figure out what control(s) have a large ViewState and look for the other things I mentioned in my previous post. You should be able to determine what is causing your ViewState bloat very easily with the tracing turned on.

-Aaron

Monday, March 26, 2012

With dynamic created Tabs extender any postback produce error, and temporary fix

I found another bug with Tabs extender:

On the page aspx

<ajaxToolkit:TabContainerID="Tab1"runat="server"Width="300px"ScrollBars="Auto"Enabled="true"ActiveTabIndex="0"></ajaxToolkit:TabContainer>

Then from server side, I add several tabs, but any button, click on that page would produce error:

Line 44: public new TabPanel this[int index]
Line 45: {
Line 46: get { return (TabPanel)base[index]; }
Line 47: }
Line 48: }
Source File:C:\Inetpub\wwwroot\AtlasControlToolkit-14384\Development\AjaxControlToolkit\Tabs\TabPanelCollection.cs Line:46

I fixed it temporarily with file TabContainer.cs, line 302 by using try and catch:

protected override void LoadClientState(object clientState)
{
Dictionary<string, object> state = (Dictionary<string, object>)clientState;
if (state != null)
{
ActiveTabIndex = (int)state["ActiveTabIndex"];
object[] tabState = (object[])state["TabState"];
for (int i = 0; i < tabState.Length; i++)
{
try
{
Tabs[i].Enabled = (bool)tabState[i];
}
catch
{
continue;
}
}
}
}

The error is still exist with the newest build# 14429. Can someone at least put the try and catch block into the new build?

Saturday, March 24, 2012

Working in Dev but not on server

Hi

I am writing my first AJAX enabled application, and I am having problems deploying it. I have created a simple autocomplete app in VS 2005 which reads values from a SQL database and returns them as an autocomplete list. This works fine on the development machine, but when I publish the app and copy the files to the server, the AJAX part of the page does not work (non AJAX parts do) I have installed the ASP.NET AJAX from http://asp.net/ajax/ on both the server and the development machine. Following publishing the app to a local drive, the only change I have made is to the SQL connection string. I have stripped the web service down to a "hello world" application to remove the connection string from the equation and this still does not work. I would be very grateful for any ideas.

Thanks

Hi,

Could you please paste the error that you are receiving here?

Thanks


You must have to install the Asp.net Ajax Framework in you server. Also you have to have the AjaxControlToolkit dll in your web application bin directory to make it working.


Turns out it was somehow related to the firewall. Worked fine bypassing the firewall. Passed to sysAdmin to sort out.

Works in VWB 2008, but not in my website

I created a nice-wroking site in VWB 2008 express edition, but when I uploaded all the files (images, all files in bin directory, default asp page and vb page, css sheet and web.config) the site gives an unknown error:http://www.wiki-pedia.co.il/

I tried to follow the directions in that page and add <customErrors mode="Off"/> to web.config but nothing happend. What should I do?

Thanks,
Yoni

What you should try to do first of all is upload a web.config that contains ONLY this:

<!-- Web.Config Configuration File --
<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>

If you were able not to figure out the problem, try to contact the support at the hosting server!

HTH,
Regards


yonidebest:

I tried to follow the directions in that page and add <customErrors mode="Off"/> to web.config but nothing happend. What should I do?

Thanks,

please make sure that the hosting company supports .Net 3.5 or .Net3.0 and the Ajax extensions issues ...


Oh darn. I wonder if I can get my money back...


I noticed that I get an error when entering Microsoft's website: "Server Error in '/' Application."
for ex.http://msdn2.microsoft.com/en-us/library/k6h9cz8h(vs.71).aspx

Why is this? I have no access to most of microsoft's site.


yonidebest:

I noticed that I get an error when entering Microsoft's website: "Server Error in '/' Application."
for ex.http://msdn2.microsoft.com/en-us/library/k6h9cz8h(vs.71).aspx

Why is this? I have no access to most of microsoft's site.

you must have access to above link, it works for me.

whats i want to mention here is that you have to make sure this site is not blocked by a proxy in your network or comapny


it doesn't work. I am a private user, I've never touch my network settings. Note that I usually use IE6 (where I get the error) but I have FF too for design purposes and the microsoft site works fine there. I noticed it doesnt work in IE6 after I installed ASP 3.5 and the framework, as well as VWB 2008. Perhaps on of these programs touched my network settings?

Yoni


Well, I don't see a better solution that contacting the hostnig support and ask them to check on the server what is happening with your website. They can help you more and on the spot!!

Thanks


Well, I turned to my hosting support and they installed what ever it was I needed. It seems to be working correctly now:
http://www.wiki-pedia.co.il/

Thanks for your help.
Yoni


I am glad it works for you!

Usually, when you are sure your work is running well locally and having problems on the server, better to email the support on the spot!!

Regards

Works on locaol Machine but doesnt work on live server

I created an atlas page:

<cc1:ScriptManagerID="ScriptManager1"runat="server"EnablePartialRendering="True">

<Services>

<cc1:ServiceReferencePath="AtlasServicestesting.asmx"Type="text/javascript"/>

</Services>

</cc1:ScriptManager>

<tableborder="0"cellspacing="0"cellpadding="0">

<tr>

<tdalign="left"valign="top"colspan="3"style="height: 8px"><imgsrc="../../images/spacer.gif"width="329"height="8"/></td>

</tr>

<trclass="copy_bold">

<tdalign="left"style="height: 13px; width: 135px"valign="top">

<span><asp:LabelID="Label1"runat="server"Text="Available Dates"></asp:Label></span></td>

<tdalign="left"style="height: 13px; width: 175px"valign="top">

<span><asp:LabelID="Label2"runat="server"Text="Location"></asp:Label></span></td>

<tdalign="left"style="height: 13px; width: 30px"valign="top">

</td>

</tr>

<trclass="copy_standard">

<tdalign="left"style="height: 13px; width: 135px"valign="top">

<span><asp:LabelID="lblDates"runat="server"Text=""></asp:Label></span></td>

<tdalign="left"style="height: 13px; width: 175px"valign="top">

<span><asp:LabelID="lblLocation"runat="server"Text=""></asp:Label></span></td>

<tdalign="left"style="height: 13px; width: 30px"valign="top">

</td>

</tr>

</table>

<br/>

<inputid="T1"type="button"value="Testing"onclick="sayHelloFromWS();"/>

</div>

<scripttype="text/javascript">

function sayHelloFromWS() {

AtlasServicesTesting.HelloWorld(onComplete);

}

function onComplete(result) {

var tb =result.getItem(0)

var i=0;

var strDates=""

var strLocation=""

var strReturn="<br />"

for(i=0;i<tb.get_length();i++)

{

strDates+=tb.getItem(i).getProperty("Dates")+strReturn

strLocation+=tb.getItem(i).getProperty("Lev")+strReturn

}

document.getElementById("lblDates").innerHTML=strDates

document.getElementById("lblLocation").innerHTML=strLocation

}

</script>

My Webservice Page just like:

<WebMethod()> _

PublicFunction HelloWorld()As DataSet

Dim StrSqlAsString

StrSql ="Select * from ref_SchoolLev where month(Actdates)=10 and Lev='G4'"

Dim StrConnAsString

StrConn ="......"

Dim myConnAsNew SqlConnection(StrConn)

Dim myAdapterAs SqlDataAdapter

myAdapter =New SqlDataAdapter(StrSql, myConn)

myConn.Open()

Dim myDatasetAsNew DataSet

myAdapter.Fill(myDataset)

myConn.Close()

Return myDataset

EndFunction

I also change the web.configure file. And the page works well when I publish the whole site to local server. But it gives me error message like: "object doesn't support this property ot method and The server method 'HelloWorld' failed with the following error:" when I publish the site to live server. I don't know why. Please help!!!

I create an Atlas page with ASP.net 2.0 webservice. It works in local server. It also works in https:// live site. But in http:// live site, it doesn't work.

Another strange thing is that even the http:// live site works on one of my co-worker's computer. We check the setting of browser and windows. But we don't know what happen. Please help!!!


I am having the opposite problem. See the threadhttp://forums.asp.net/thread/1482244.aspx

My test server does not use https, but production does. Maybe it has something to do with the way the asp.net ajax *.js files are cached the first time (secure vs. nonsecure). I'm going to try clearing my browsing history...


This didn't help.

Wednesday, March 21, 2012

XML and Webserivces

Hi All,

I have created a webservice that returns XML data to be processed by the client.

The returned XML contains a complex type that I created, as well as having a number of nested objects on which I have used the XMLARRAY / XMLARRAYITEM.

Fragment of test XML shown below...

<?xmlversion="1.0"encoding="utf-8"?>

<Testxmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:xsd="http://www.w3.org/2001/XMLSchema"xmlns="http://tempuri.org">

<test1>201</test1>

<test2>Blah Blah</test2>

<test3>3</test3>

<test4>51</test4>

<TestTest>

<Inner>

<inner1>300</inner1>

<inner2>TEXT</inner2>

<inner3>TEXT</inner3>

<inner4>TEXT</inner4>

<inner5>TEXT</inner5>

<inner6>TEXT</inner6>

<inner7>TEXT</inner7>

<inner8>TEXT</inner8>

<inner9>TEXT</inner9>

<inner10>TEXT</inner10>

</Inner>

<Inner>

<inner1>301</inner1>

<inner2>TEXT</inner2>

<inner3>TEXT</inner3>

<inner4>TEXT</inner4>

<inner5>TEXT</inner5>

<inner6>TEXT</inner6>

<inner7>TEXT</inner7>

<inner8>TEXT</inner8>

<inner9>TEXT</inner9>

<inner10>TEXT</inner10>

</Inner> </TestTest>

</Test>

Now when I use the test harness the XML is generated exactly as I require.

Also I can reference the returned data on the client, for example by using arg.test1 would return '201'.

My probelms/question are these...

1> How do I access the inner array items. For example how would I access elements under TestTest?

2> How do I convert the returned data from the webservice into valid xml on the client? Every time I try and do this I get the error 'XML document must have a top level element'.

I cant understand why it says it is not valid as every other application I have has no problem with the XML that is generated,

Can anyone point me in the right direction as I cant see where the problem is.

Thanks in advance

Problem sortedSmile

Once I found out about the service using JSON by default it was very straightforward.

I looked at the JSON formatted data that was sent with the response. From there it was obvious how to call the array items.

For example arg.Level1[1].Level2Value

Didn't know much about JSON before this but it is a great format (compared to XML) to use when you want to handle stuff on the client in javascript. Even handles custom objects with ease.

Hope this helps somebody