Wednesday, March 28, 2012

Why IsPostBack=false? How to repair that?

I'm using Ajax.Net. There is UpdatePanel on the page. It contains GridView. When I press "Edit", "Update" or "Cancel" button in the GridView then UpdatePanel reloads. Also executes code "if (!IsPostBack) { ... }" in Page_Load event on the server - but I don't need it!!! This code must run only once when page is loading for the first time.

protected void Page_Load(object sender, EventArgs e) {if (!IsPostBack) { ...// Here there are bindings for each control. // This code must run only once ...// On every action with GridView (which is placed in the UpdatePanel) // this code executes again and again. // Why? And how to prevent that? } }

1) Why IsPostBack=false (in Page_Load) on any action with GridView?

2) How to prevent that?

when you are clicking the button it's like you are reloading the all page but not the design... If you do not bind again the gridview loses data... Best solution is to cache the datatable that binds the gridview and binding the gridview to that... You can always verify the state of the grid to verify if you do some code...

As I understood, on every asynchronious postback (or mayme it's callback) the page is creating as it is not postback (isPostBack=false).

I think that it is better to use Session instead of Cache because every user has it's own data in the tabe.


cache in client... it's not postback... because the reference it's different... when you have difficulties test without the updatepanel to see if it's another reference of the page or not...

and i know what you're thinking the adress it's the same... it's ASP my friend... works that way.


What means "cache in client"? How? I can cache data only on server.


HttpContext.Current.Cache.Insert(itemString, Obj, HttpCacheability.Public, DateTime.Now.AddHours(expiration), TimeSpan.Zero)



Oh, it's caching on the server side, I thought you means caching data on the client side.

I change a bit my question. So, on each asynchronious postback executes code "if (!IsPostBack) { ... }" in Page_Load. But I want to prevent it. This code must executes only once when page is loading for the first time. How can I know if the page is loading for the first time or it is asynchronious postback? I want something like that: "if (!IsPostBack && !isAsynchroniousPostBack) { ... }"


did you tried with page.callback?


most likely no. what do you mean?


Put if not ispostback and not iscallback...


I wrote "!IsPostBack && !IsCallback && !IsAsync" - IsCallback and IsAsync always =false. IsPostBack in some cases =true and in some cases = false


tell me what are the cases that give true...

you don't have the need to put all of this...

if it doesn't control for you the postback you can put a viewstate that keeps the state of the grid.

just like this:

If not ispostback and viewstate("Should_Enter_Here")

end if

and in the event of the grid put this viewstate equals a true.


What you are looking for isIf (!ScriptManager.GetCurrent(Page).IsInAsyncPostBack).

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


Thanks

Why it always return to the original place?

<asp:ScriptManager ID="ScriptManager1" runat="server" />
<cc1:DragPanelExtender ID="DragPanelExtender1" runat="server" TargetControlID="Panel1"
DragHandleID="Panel2">
</cc1:DragPanelExtender>
<asp:Panel ID="Panel1" runat="server" Height="300" Width="200">
<asp:Panel ID="Panel2" runat="server" Height="25" Width="200" BackColor="Black">
</asp:Panel>
Test</asp:Panel>

I would like the Panel1 can be dragged and stay the place where I drop it.

How to do that?

I believe the body of the page has to have been assigned some sort of physical dimension:

http://forums.asp.net/p/1150327/1874846.aspx

See point #23 and Listing 6 of this article:

http://aspalliance.com/1450_Working_with_DragPanel_AJAX_Control.4


Many thanks for replying.

Why javascript function can not be found in Firefox with a AJAX page?

Following page works fine with IE. When click on Html button, the javascript function is called and works fine.

But when run the same page in Firefox, it reported that the error as below:

myFunction is not defined

onclick(click clientX=0, clientY=0)

What's the possible reason and how to solve it?

--the page code:the page also include some Ajax toolkit and the code for that is omitted.

<%@dotnet.itags.org. Page Language="vb" AutoEventWireup="false" Codebehind="workshop.aspx.vb" Inherits="my.workshop" %>
<!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>Workshop Registeration</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<link href="http://links.10026.com/?link=StyleSheet1.css" rel="stylesheet" type="text/css" />
<script type="text/jscript" language="javascript" >

function reset(){
document.workshop.reset();
}

function myFunction() {
alert("test");
}

</script
</head>
<body class="page">
<form id="workshop" runat="server">
<asp:ScriptManager runat="server" EnableScriptGlobalization="true" ID="MasterScriptManager"
EnablePartialRendering="true" ScriptMode="Release" AsyncPostBackTimeout="72000">
</asp:ScriptManager>
<div>
<table border="1" cellpadding="0" cellspacing="0">
<tr class="namearea">
<td align="center" class="dataarea">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="right" style="width: 50%">
<input class="jsbutton" onclick="javascript:myFunction();" type="button"
value="Button1" />
</td>
<td align="left" style="width: 50%; background-color: White;">
<br />
<asp:PlaceHolder ID="plcmyHolder" runat="server"></asp:PlaceHolder>
<br />
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>

Change the script type from text/jscript to text/javascript and it'll work.

why Javascript doesnt work properly in updatepanel?

i wanna my gridview to change into editrow model by click any space in the row , so i wrote in the aspx page:

.....
<script type="text/javascript">
function ClickEvent(cId)
{
var id=cId;
document.getElementById("rowid").value=id;
document.getElementById("btnBindData").click();
}
</script>
.....

<asp:LinkButton ID="btnBindData" runat="server" OnClick="btnBindData_Click" Width="0px" style="width:0px; height:0px"></asp:LinkButton>
<input type="hidden" id="rowid" runat="server" /> //send clicked row index to editindex property

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1"
OnRowDataBound="GridView1_RowDataBound">
<Columns>
<asp:BoundField DataField="userName" HeaderText="userName" SortExpression="userName" />
<asp:BoundField DataField="userPassword" HeaderText="userPassword" SortExpression="userPassword" />
</Columns>
</asp:GridView>

In the aspx.cs file i wrote:

.......

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{

e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#dfe345'");

e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");

e.Row.Attributes["style"] = "Cursor:hand";

e.Row.Attributes.Add("OnClick", "ClickEvent('" + e.Row.RowIndex + "')");

}
}

......

protected void btnBindData_Click(object sender, EventArgs e)
{
GridView1.EditIndex=Convert.Int32(this.rowid.Value);

.....

GridView1.DataBind();
}

It works well without UpdatePanel ,but when put the GridView in the UpdatePanel ,when I click the row, the GridView got disappeared.

Replace asp:LinkButton with asp:Button. If you want you can sorround your button with a hidden div (to hide from the user). Also add UseSubmitBehavior="false" to the asp:Button.

For example:

<div style="display: none; line-height: 0pt;">
<asp:Button id="btnBindData" runat="server" OnClick="btnBindData_Click" UseSubmitBehavior="false" />
</div>

Why JSON?

Say, please, what was the main reason to use JSON object serializing in Atlas instead of SOAP? Easy deserializing? Or light weight? Or something else?

And will Atlas support SOAP in the future?

Thanks.

Pavel,

Easy deserializing is indeed a big part of it. The ability to just call JavaScript's 'eval' instead of having to reconstruct an object graph from an XML DOM makes JSON much easier to you. JSON is also a more concise format.

It is conceivable that Atlas will support SOAP in the future.

David


Thanks for quick answer.

Why Microsoft done this in Ajax

Hello,

Till the time i have heard that Microsoft is releasing the ASP.NET AJAX i am excited that i have to just copy the dll's of this ASP.NET AJAX into my webapplication becaz earlier i have used Atlas products dll in my application , in that i just cpoied the dll into the bin folder of my application and its working perfect.

But i can't understand the reason why Microsoft have removed this feature from his new release ASP.NET AJAX, they know this that many websites running on hosted servers and they d't have permission to install any software on that server still they have done this,

Can any one explain me why they have done this is there any reason for this, Is ASP.NET AJAX not working fine in the din folder or Wht?

Now with ASP.NET AJAX you dont need to copy the ajax framework dll into the bin directory as you used to do with ATLAS. When ASP.NET AJAX was installed, these dll's will be installed directly into the GAC and all most all the hosting providers might have done this already. You just need to re-configure your web.config file and also keep track of the changes from ATLAS to BETA to RC which can be found at

Converting Applications from "Atlas" CTP to ASP.NET AJAX RC
Converting Applications from ASP.NET AJAX Beta 2 to ASP.NET AJAX RC

Its not that ASP.NET AJAX is not working fine with the bin folder. With each and every release, there will be changes like adding new functionality, bug fixing etc..,

Thanks

Why mix live.com with ATLAS? or even pageflakes?

I am not sure if other people has the some question as I have. I am using ATLAS, and trying to find out what features are available. There are more features to come, but I need keep looking what are available since I don't want to deveope them if they are there ready for use.

But look on the ATLAS pages, often you will see pageflakes, live.com etc. They are good sites, they are using ATLAS. But the thing is they don't build with ATLAS only. So my question is what is the point to put them here, just let us admire the nice features they have but no way to build our site like thme?

hello.

well, i guess that is what you'll have to do with everything, ie, you'll allways have to expand/tweak it to fit your needs. seeing sites like those might give you new perspectives about what you can do with the platform.

Why must I double-click the Confirm/Cancel Buttons of a ConfirmButtonExtender

Hello everybody

I'm using ConfirmButtonExtenders in my pages, but I have got an issue with them: I must double click the confirm or cancel buttons in order for something to happen.

I've typed no code but

<ajaxControlToolkit:ConfirmButtonExtender runat="server" ID="CBESupprimerIB" TargetControlID="LBSupprimerAnnonce" ConfirmText="<%$ Resources:Resource, RLConfirmSuppression%>"></ajaxControlToolkit:ConfirmButtonExtender>

Why is this ?


Thanks for your help

Hi,

It's hard to tell why from your description. I tried it, and can't reproduce the issue.

Can you investigate more and be more specific about how to reproduce it?


Simple error that concentration would have helped me to catch:

I simply had two Extenders and both extended the same Button so that I needed two click twice to validate my choice.

Thank you for telling me to investigate more, this helped me find where the issue came from...

Why My AutocompleteExtender doesnt work Im gone crazy!!

Hi All!!!

I'm looking for help. I read lot of post in this forum but my AutocompleteExtender still not work. Can somebody help please!

this is my code behind of my Webservice

1using System;2using System.Data.SqlClient;3using System.Web;4using System.Collections;5using System.Collections.Generic;6using System.Web.Services;7using System.Web.Services.Protocols;8910/// <summary>11///12/// </summary>13[System.Web.Script.Services.ScriptService]14[WebService(Namespace ="http://tempuri.org")]15[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1, EmitConformanceClaims = true)]16public class AutocompleteList : System.Web.Services.WebService {1718 public AutocompleteList () {1920//Uncomment the following line if using designed components21 //InitializeComponent();22 }2324 [WebMethod]25 [System.Web.Script.Services.ScriptMethod]26 public string[] GetList(string prefixe, int count)27 {28 List<string> art = new List<string>();29 string cnx = global::System.Configuration.ConfigurationManager.ConnectionStrings["artistesSQLServices"].ConnectionString;30 string select = "SELECT DISTINCT nom FROM [Table] WHERE nom LIKE @dotnet.itags.org.VALUE";31 SQLServer server = new SQLServer(cnx);32 if (server.Connect.State == System.Data.ConnectionState.Open)33 {34 SqlDataReader reader = null;35 SqlCommand cmd = new SqlCommand(select, server.Connect);36 cmd.Parameters.Add(new SqlParameter("@dotnet.itags.org.VALUE","%" + prefixe + "%"));37try38 {39 reader = cmd.ExecuteReader();40 cmd.Parameters.Clear();41 }42catch (Exception ex)43 {44string mess = ex.Message;45 }46finally47 {48if (reader.HasRows)49 {50while (reader.Read())51 {52 art.Add(reader.GetValue(0).ToString());53 }54 }55 reader.Close();56 reader.Dispose();57 cmd.Dispose();58 server.SQLDisconnect();59 }60 }61return art.ToArray();62 }63}

this is the code of my aspx page

<%

@dotnet.itags.org.PageLanguage="C#"MasterPageFile="~/users/Site.master"AutoEventWireup="true"

CodeFile

="Test.aspx.cs"Inherits="users_Test"Title="Untitled Page" %>

<%

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

<%

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

<

asp:ContentID="Content1"ContentPlaceHolderID="ContentPlaceHolder1"Runat="Server"><asp:ScriptManagerID="ScriptManager1"runat="server"EnablePageMethods="true"EnablePartialRendering="true"></asp:ScriptManager><ajaxToolkit:AutoCompleteExtenderID="AutoCompleteExtender1"runat="server"TargetControlID="TextBox2"ServiceMethod="GetList"ServicePath="../AutocompleteList"CompletionInterval="10"CompletionSetCount="10"MinimumPrefixLength="3"Enabled="true"EnableCaching="true"></ajaxToolkit:AutoCompleteExtender> <asp:TextBoxID="TextBox2"runat="server"></asp:TextBox>

</

asp:Content>

Hi,

Change your First Parameter "string prefixe" to be "string prefixText" . The Parameters are hard-coded in the WebService Invocation.

Check this Thread ..http://forums.asp.net/1598039/ShowThread.aspx#1598039


thanks for your help phanatic it works very well ............ BUT in debug mode only

when i call my page by this url :http://mymachine/mypage.aspx the autocompletion doesn't work. Do you know why?


ok,

we are making progressSmile

I see that you are calling an ASPX Page , are you trying to use the PageMethods ?

If you are , Please checkhttp://forums.asp.net/thread/1205564.aspx

If it resolves your issue , please mark my reply as the answer


still doesn't work!

I have "myage.aspx" which contains the autocompleteextender, and 2 others files (Autocomplete.asmx and Autocomplet.cs) which contains the code of my webservice


still doesn't work!

I have "myage.aspx" which contains the autocompleteextender and the two files of my webservice the "Autocomplet.asmx" and the code-behind "Autocomplete.cs"


hi,

Please drop me a sample at Phani_Rajyn@.yahoo.co.in


i've just sent you a sample

Hi ,

The sample contains SQLDataSource Connections and a lot of dependencies .

I cannot run this on my machine

can you please send me a self-contained sample that can run anywhere ?


hi phana

i've done some test with an other code in my webservice like this

1[WebMethod]2 [System.Web.Script.Services.ScriptMethod]3public string[] GetCompletionList(string prefixText,int count)4 {5int i = 0;6int iLength = 10;7 List Values =new List<string>();8for (i = 0; (i < iLength); i++)9 {10 Values.Add(Convert.ToString(prefixText + i.ToString()));11 }12 String[] strReturn =new String[Values.Count];13 strReturn = Values.ToArray();14return (strReturn);15 }

this code work very fine in debug mode and in normal mode. In my code i'm connecting to a SQLSERVER 2005 in an other machine.


I've done a test

I code a new page aspx just with the textbox an the autocompleteextender

i try my webservice it works fine. but when i add my website in IIS the autocompletextender doesn't work. it seems to be an issue in my IIS settings con you tell me what are the settings for IIS please


Hi,

"this code work very fine in debug mode and in normal "

If the code above works , then there are no issues with the AutoCompleteExtender , you should investigate the calls to the SQL Server you are making to understand what the issue is .

As far as IIS is concerned, are you gettting any errors related to IIS configuration ?


i find the issue it seems that IIS don't use my authentification to connect to the sqlserver

i've change my connection string and use the "sa" id user and password to connect

thx a lot for your help phana


just an other question can tell me how can i do a drag n drop from a textbox to an other textbox?

Hi,

great to know that we resolved the issue.

Can you please mark my reply as the answer ?

Why my web services cant accept parameter?

When my javascript call the echoString(s) in the following code, it return nothing

<%@dotnet.itags.org. WebService Language="C#" Class="WebService" %>

using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class WebService : System.Web.Services.WebService {

[WebMethod]
public string echoString(string s) {
return s;
}

}

The strange things are my .NET program works fine with the code above and my javascript client program doesn't work with the code above but works fine with other people's web services. EX:

http://www.mssoapinterop.org/asmx/simple.asmx?op=echoString

What is wrong with my code? Thank you!!!!!!!!!

asdpai:

what is wrong with my code?

nothing, code is correct. Decorate youre WebService with theSystem.Web.Script.Services.ScriptService() and the WebMethode with the ScriptMethod() attribute eg.

<%@. WebService Language="C#" Class="WebService" %>

using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
usingSystem.Web.Script.Services;

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService()]
public class WebService : System.Web.Services.WebService {

[ScriptMethode()]
[WebMethod]
public string echoString(string s) {
return s;
}

}

Hope that coul help.

Why no Atlas Web Site template?

Hello -

Just getting started with Atlas. Downloaded and installed ASP.NET AJAX 1.0 Beta 2 and ASP.NET 2.0 AJAX Futures November CTP, but when I go to open a new Web site in VS2005, "Atlas" Web Site does not appear under My Templates (as the tutorials indicat should be the case).

What does appear under Installed Templates is ASP.NET Ajax-Enabled Web Site and ASP.NET Ajax CTP-Enabled Web Site. I chose the latter; however, none of the controls with the Atlas prefix (such as <atlas:ScriptManager>) are available to me through type-ahead.

Any suggestions on this are appreciated.

Eric

I just posted the same issue 15 minutes ago, Can please pass along any information if you come up with a fix.


In beta 2 version, prefix 'atlas' is replaced by 'asp'.
In beta 2 version, prefix 'atlas' is replaced by 'asp'. I am not sure what this means... Details please.

The responder means:

<atlas:ScriptManager>)

is now

<asp:ScriptManager>)


Does this mean that we no longer need the Atlas Web Site Template? Is it replaced with the ASP.NET AJAX-Enabled Web Site?
That is correct forget you even heard the word Atlas (its all Ajax now)
Thanks for the help. I am new at this programming and I have a lot to learn in a little time.

Hi,

When you install AJAX Extensions Beta2, It will adds some controls to Visual Studio2005 ToolBox.

So, open one ASP.NET website and click the ToolBox, goto AJAX Extensions Tab, click that Tab, it will show all controls which are newly installed.

All controls[UpdatePanel,..] will starts with 'asp'.

in design mode, drag-and-drop one control into the design view and goto the source view, there you will see the AJAX controls syntax.

Pradeep

why not EnablePartialRendering="true"?

why the attribute is not set by default, is there any specific behavior?

enablePartialRendering

="true"

Yes - it changes the way script manager deals with the page. This allows UpdatePanel to work. Without an UpdatePanel on the page, you don't need it enabled.


thank- i see that

but isnt the update panel the mostly used? or ... activate the partial reendering when update panel comes to page ...


I haven't worked through all the scenarios here, but one of them is that the UpdatePanel has some issues in Safari right now. Perhaps this question would be better suited for the general Atlas forum. Thanks!

Return Value

true if partial rendering is enabled and full-page updates are suppressed; otherwise,false. The default istrue.

Remarks

Even if theEnablePartialRendering property istrue,partial-page rendering might not occur for the following two reasons:the browser does not support partial-page rendering or theSupportsPartialRendering property is set tofalse.

You can override the value of theEnablePartialRendering property at run time during or before the page'sInit event. If you try to change this property after the page'sInit event has occurred, anInvalidOperationException exception is thrown.

why now i cant use the namespace Sys.Data

How i can create a datatable in javascript to pass to a webmethod now if the namespace Sys.Data is removed?

Thanks

Just add the Preview version.

why page load is called when an updatepanel is updated

Hi,

i have just observed that when a request is posted to server inside an updatepanel. then load method of page is called.

create a page with script manager and updatepanel. put a button inside the panel. add a msgbox in the load eventhandler of page.

now when u will click the button page load eventhandler would be executed. i was expecting that only the load event of update panel would be executed not the page one. because what ajax says is that whole page is not reloaded only the updatepanel is reloaded. does it mean that the ajax only helps to not activate the back button on browser but underlying it reloads the page in fact.

thanks

Hi i think you misunderstood something. what AJAX meant for is not exactly for asynchronous postbacks. This means that you cant execute two threads parallelly. But what it does is partial rendering. During an async postback all the usual events will be executed but only the contents inside the Update panel will be rendered.


hello.

well, what they're trying to say is that only the updatepanel contents will be updated during a partial postback. you can use the scriptmanager isinasyncpostback property to see if you're in a partial postback scenario:

http://asp.net/AJAX/Documentation/Live/mref/P_System_Web_UI_ScriptManager_IsInAsyncPostBack.aspx


rex_alias:

Hi i think you misunderstood something. what AJAX meant for is not exactly for asynchronous postbacks. This means that you cant execute two threads parallelly. But what it does is partial rendering. During an async postback all the usual events will be executed but only the contents inside the Update panel will be rendered.

I'm pretty sure that's exactly what AJAX is meant for.

And you can execute two threads parallelly.

Partial rendering isn't related to AJAX, you can have partial rendering without AJAX, and you can have AJAX without partial rendering, although it's implemented in the UpdatePanel and its implementation uses AJAX.

And yes, the whole life cycle of the page happens on the server, but only the relevant portions of the output are rendered into a xml based diff-gram, and sent to the client.


This is the nature of Update Panel. You can filter out the Regular Post Back with an Async by Checking the Page ScriptManager.IsInAsyncPostBack. Or if you do not want to page to be called then use the Client Centric Development Model which is calling the Web Service or Static Page Methods.

Why Popup Calendar doest trigger textbox event OnTextChanged?

A textbox connect to an Atlas Toolkit Control PopupCanendar.
There is a javascript for OnTextChanged event of this textbox.

When using popup calendar to select a date for this textbox, it doesn't trigger this event.
But if type date in textbox directly, it is OK. the OnTextChanged will be fired.

Why? what's the solution for this case?The DOM is a little weird in that script changes don't tend to fire the associated event handlers that get fired when the user makes a change. It sounds like you're hitting that here. It's possible to fire the event from script, too, so maybe you want to try that. If you switch to PopupControl's CommitScript mode, I think you should be able to make this change fairly easily.

Why POST is slower than GET?

Sorry, my question can be silly and a little OT, but I'm really stuck on it...I'm performing some tests with AJAX, actually I'm not using a particular framework or some already written Javascript code. The test is just a simple HTML page that sends (one after the other) 10 requests to another page (in the same site). I'm writing out the time elapsed between the request and the response of every one. When I try this page on my local web server I get very fast responses (more or less 0.01 seconds), with both IE7 or FF2. When I do the same test from another machine (in the same network, and the network has not problems of traffic) I have totally different results. If the page is performing a GET to the server the requests are very, very fast with boht IE7 and FF2. But if I change the GET to a POST (with very few bytes of data) FF2 because much slower (0.25 seconds) and IE7...I don't know...on some machines is still very fast, but on others is as slow as FF2. I can't understand when and why?!? I tried with IE7 on XP (fast), IE6 on XP (fast), IE7 on Vista (some fast and others slow)...there are too many variables, I'm really stuck and I can't understand the difference between these machines. The security parameters seems to be the same, I tried to change them at once...

Please, help me

Cold

This is a great article about why HTTP Post is more expensive than GET. Basically it queries twice and sends more bytes over the wire.

http://msmvps.com/blogs/omar/archive/2006/09/22/Atlas-2_3A00_-HTTP-POST-is-slower-and-it_2700_s-default-in-Atlas.aspx


Thank you very much for your reply. The problem is I'm not using any framework at all and all the requests I'm doing I have written in Javascript code by myself. I checked the code many times, but I couldn't find any problems on it. And I don't have the problem of the double request, as I'm sending just one POST request with the body togheter. And, even if I found a reason for the POST to be slower than the GET, I could not understand why in some machine every request is slow and in others they are so fast (using IE)! There should be some reason, but until now I didn't find any...


I don't understand what about the article doesn't apply to your situation. Basically

1) the browser waits for the server to respond "100 Continue" before the form is submitted. There is no such delay for GET requests.

and 2) the data itself contains additional info such as content types and etc. There are actually 2 requests going on for each POST, and the actual data is twice as long. It's nothing to do with you actually manually sending 2 requests.



This can be true using Atlas, but I'm actually monitoring the requests using Fiddler, and I don't have 2 requests! I have just one request, with the body I have specified on the send() method. I don't have any of the behaviours that the article is talking about. There is just an HTTP request (with method POST) and the resposte to the request, nothing more!

Hope this help to understand my problem...

Cold

Why Properties Sub Controls?

I don't understand why ACT always uses a special sub control within its controls.

Usually in ASP.NET controls are designed to have attributes on their own. Why this design?

TIA,

Axel Dahmen

Hi Axel,

The Toolkit sits directly on top of the ASP.NET AJAX Framework, which chose to use this approach. I think it's because this is how control extenders work in WinForms and they were going for a familiar approach - but this has actually been changed in the beta so that the properties, etc., have been moved up to the extenders.

Thanks,
Ted

Why Response.Redirect() opens up a new browser window in AJAX?

I have an AJAX enabled page displayed in amodal dialog, When I click on a button that has a Response.Redirect() code, a new browser window gets opened, which is weird and not the behavior that I expect.

I should note that this page worked properly before adding the AJAX related stuff.

I highly appreciate any insight into this problem.

try use server.transfer


I had already tried the Server.Transfer but I got a client side alert: "Sys.WebForms.PageRequestManagerParserErrorException: The message recieved from the server could not be parsed,..."
Try to navigate to next page in Javascript instead of on Server side. I think this can solve the issue.

hello.

i think the problem is that submitting a page on a popup will open another window by default. you can workaround this by adding an iframe to your popup window which loads the page you need.


Thanks, I think the only workaround to my problem was to use the IFrame in the modal window, but still, I'm wondering why the use of Server.Transfer() caused the error in AJAX, and, why the Response.Redirect() would open up a new window, was I missing somthing or it's just the way AJAX works!

May I ask that Response.Redirect is logical/possible at all during a partial postback (for example in an updatepanel's button click event)?!

Simply move that specific button which yield Response.Redirect outside of the updatepanel, maybe it helps.


Yes, the button which yielded the Response.Redirect() or Server.Transfer() for that matter, was inside the UpdatePanel, I moved it outside the UpdatePanel and my problem was solved. Actually the UpdatePanel was inside a Container UserControl, I think I should make use of UpdatePanel more narrowly focused.

Thank you very much indeed.


response.redirect will be correctly interpreted by the ajax platform. you can check this by using ?a "normal" page. the problem that was happening here was related with modal dialogs and the issue described is not an ajax problem.

server.transfer won't work correctly with ajax and shouldn't be used from controls placed inside the updatepanel. this is understandable because partial postbacks expect to receive a predefined message from the server and whe you do a server.transfer you end up retunring a new page to the user which doesn't conform to the expected message.

So response.redirect works with ajax.

If ajax open the redirected page via javascript (maybe using window.open( ... ) ), that can be a problem.

Modern tabbed browsers are configurable how to treat popup pages from normal links or from javascript (new window, same window, new tab, disable totally javascript popups etc.)

I recommend for Robert to try the page in firefox, and play with advanced firefox settings (type about:config in the address bar, and play with "browser.link.open_newwindow.restriction" and similar settings, you can google for help how it works)

ps:

If the button must be in the updatepanel, maybe it is possible to register a script in the server side which open the new window by javascript (a more controlled way.)


I am also running into this problem and am unable to place the control outside of the Update Panel. I am not clear as to how an IFrame would be implemented. Is it meant that an IFrame should be used in place of the AJAX update panel or in addition to? How would this implementation work specifically?

Thanks for any information in advance.


MaybeScriptManager.RegisterPostBackControl could be used to eliminate this problem in some cases.

So leave your button (which has the codebehind redirect logic) in the updatepanel, but use the RegisterPostBackControl method so it will cause a full normal postback. That way you have a normal redirect, not the ajax client side redirect.


Thanks for the responses.

I did try the following on the control that is being clicked to fire the Redirect:

ScriptManager1.RegisterPostBackControl(this.testButton);

Unfortunately, this still launches a new window during the redirect.

Does anyone have any other ideas as to how i can do this? I would be open to attaching some javascript to the button in order to perform the redirect, however, I have already tried adding the following with no success:

ScriptManager.RegisterClientScriptBlock(this.buttonTest,this.buttonTest.GetType(),"Redirect","window.location = 'http://www.testpage.com'",true);


jriell:

I have already tried adding the following with no success:

ScriptManager.RegisterClientScriptBlock(this.buttonTest,this.buttonTest.GetType(),"Redirect","window.location = 'http://www.testpage.com'",true);

If you choose that way (custom client side redirect), I recommend the following to try:

Put a regular input button, link etc. in the updatepanel, for example:

<input type="button" value="test" onclick="window.location.replace( 'http://www.testpage.com' );" />

If that works, try the script withthe RegisterClientScriptBlock stuff.

why ScriptManager is not recognized by VS?

Hi,

I drag and drop AJAX ScriptManager control to the source view of default.aspx, here is the code (the third and fourth lines are for ScriptManager):

<%@dotnet.itags.org. Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
Status:
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True">
<asp:ListItem Selected="True" Value="false">Active</asp:ListItem>
<asp:ListItem Value="true">Complete</asp:ListItem>
</asp:DropDownList>

But I found ScriptManager tag is underlined with curly red line. When I mouse hover on ScriptManager tag, I see a tip

Element ScriptManager is not a known element. This can occour if there is a compilation error in the website.

But I could compile and run the site successfully. The bugging thing is that all the AJAX control, such as UpdatePanel is not recognized by VS too.

any idea?

Thx

Tao

From what I know, this is what is happening...

The cause for this error is, in your web.config look for this tag...and change the tagprefix from default asp to anything else...

<controls>
<add tagPrefix="ajax" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</controls
and now change the <asp:UpdatePanel> to <ajax:UpdatePanel> . All your errors should be gone.

please Let us know if this fixes...


This does solve the problem. But I don't understand why. Originally, the AJAX control defined in System.Web.Extensions is registered as tagPrefix = asp. So when I use asp:ScriptManager tag, VS should be able to locate the assembly and recognize it, theoritically. Do you know why I have to replace "asp" prefix with something else, such as ajax?

Thx

Tao


Theoretically I too expected the same. We found this fix on some blog(Thanks to him for posting it), I forget the link!. But it solved the dirty red squiggly lines and I made a note of it. May be, experts here can give hind sight of why and the details behind this...

Happy Coding :)

Why ScriptManager in MasterPage is not enough to the toolkitExtender control?

This is the error I get when look on a page and drop the User control that include the ajaxTooltip from any type.

Any suggestion?

The Error

Do you use ScriptMangerProxy?you need to use ScriptManager/ ScriptManagerProxy both for master page.

Where to add the ScriptManager and where to add the ScriptManagerProxy to get a clear design time project developing?

To explain the controls, pages, masters I have, here are they:

1. A master page that include a ScriptManager (I try to include a ScriptManagerProxy also).

2. A page that inherit the MasterPage and have a User Control in it by design time(drag and drop).

3. A User Control that have a modalPopupExtender in it, that work properly.

My only problem that other developers use my User Control in them Pages and the User Control(that added to the page) raise a:

Error Rendering Control

An unhandled exception has occurred.

The control with ID 'MpdalPopupExtender1' requires a ScriptManager on the page. The ScriptManager must appear before any controls that need it.

What can I add to the Page, Master or may be web.config?

why script enabled webservice making postback to server?

My WebPage has two textbox & one button.On button click I call script enabled webservice asynchronously still why my page go for postback to server?

<%@dotnet.itags.org.PageLanguage="C#"AutoEventWireup="true"CodeFile="page2.aspx.cs"Inherits="page2" %>

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

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

<headrunat="server">

<title>Untitled Page</title>

<scriptlanguage="javascript"type="text/javascript">

<!--

function Button1_onclick()

{

ret= WebService.Hello(document.getElementById('TextBox1').value,OnComplete,OnTimeOut,OnError);

return(true);

}

function OnComplete(args)

{

document.getElementById('TextBox2').value=args;

}

function OnTimeOut(args)

{

alert('Timeout');

}

function OnError(args)

{

alert('error');

}

// -->

</script>

</head>

<body>

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

<div>

<asp:TextBoxID="TextBox1"runat="server"></asp:TextBox>

<asp:ButtonID="Button1"runat="server"Text="Button"OnClientClick="Button1_onclick();"/>

<asp:TextBoxID="TextBox2"runat="server"></asp:TextBox>

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

<Services>

<asp:ServiceReferencePath="WebService.asmx"/>

</Services>

</asp:ScriptManager>

</div>

</form>

</body>

</html>

===============================================

WebService

using System;

using System.Web;

using System.Collections;

using System.Web.Services;

using System.Web.Services.Protocols;

///<summary>

/// Summary description for WebService

///</summary>

[WebService(Namespace ="http://tempuri.org/")]

[WebServiceBinding(ConformsTo =WsiProfiles.BasicProfile1_1)]

[System.Web.Script.Services.ScriptService()]

publicclassWebService : System.Web.Services.WebService {

public WebService () {

//Uncomment the following line if using designed components

//InitializeComponent();

}

[WebMethod]

publicstring Hello(string msg) {

return"Hello"+msg;

}

}

function Button1_onclick()

{

ret= WebService.Hello(document.getElementById('TextBox1').value,OnComplete,OnTimeOut,OnError);

return false; // return(true); you need to return false instead of true. if you return false it doesn't do post back.

}

Thanks,

Kiran


Still same condition it does post back.I tried same application with HTML controls textboxes & button it works fine but when I tried with server side control it posts back


Hi,

can you post code that you used for testing.

Thanks,

Kiran


here is code with HTML textboxes & button for same script enabled webservice

<%@.PageLanguage="C#"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="_Default" %>

<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.1//EN""http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <htmlxmlns="http://www.w3.org/1999/xhtml">

<headrunat="server">

<title>Untitled Page</title>

<scriptlanguage="javascript"type="text/javascript">

<!--

function Button1_onclick()

{

ret= WebService.Hello(document.getElementById('Text1').value,OnComplete,OnTimeOut,OnError);return(true);

}

function OnComplete(args)

{

document.getElementById('Text2').innerText=args;

}

function OnTimeOut(args)

{

alert('Timeout');

}

function OnError(args)

{

alert('error');

}

// -->

</script> </head>

<body>

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

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

<Services>

<asp:ServiceReferencePath="WebService.asmx"/>

</Services>

</asp:ScriptManager>

<div>

<inputid="Text2"type="text"/>

<inputid="Text1"type="text"/>

<inputid="Button1"type="button"value="button"language="javascript"onclick="return Button1_onclick()"/>

</div>

</form> </body>

</html>


Hi,

function Button1_onclick() still returns true.

did you change it to return false. and tried it.

Thanks,

Kiran


yeah.......I did change it to false & tested it ,it does post back .The code which I posted doesn't postback but its withHTML control which works fine & I am trying to do same webservice code but with server control.

Hi,

can you change below code

<asp:ButtonID="Button1"runat="server"Text="Button"OnClientClick="Button1_onclick();"/>

to

<asp:ButtonID="Button1"runat="server"Text="Button"OnClientClick="return Button1_onclick();"/>

make sure that function is called. keep alert message in Button1_onclick function so you know that function got invoked when you click Button1_onclick.

Thanks,

Kiran


Thank you Kiran it works just fine.But I didn't get difference b/nButton1_onclick() & return Button1_onclick() could you please explain it?

Thanks

Manisha.


event = "return function()" if function returns false the event gets canceled.

if your case we are forcefully canceling onclick event by returning false.

event = "function()" doesn't matter what function returns.

Thanks,

Kiran

why should i not use magic ajax?

can any tell me , what are the disadvantages of magic ajax?

or any bottle neck? its very easy to use, and its working, but i have to take desccion either to use it or not? please share your experience with magi?

Magic AJAX might not integrate with ASP.Net as seamlessly as ASP.Net AJAX. Remember ASP.Net AJAX and ASP.net both are build by the same company Microsoft. They know better how both work so they can make integration very tight. Furthermore, ASP.Net AJAX is free why would anyone go for Magic AJAX?


It doesn't look very mature, compared to ASP.NET AJAX, and you'd be drastically limiting your support options by going with an obscure framework.

Why avoid ASP.NET AJAX?


hmm, ok thanks for both of you, i dont know i install ajax tookit but its not working, :(

and i found magic ajax very easy,,, any way, i ll try my best to use asp.net ajax rather magic,

Thanks Alot


hai magic ajax for asp.net 2.0 is not supporting page store mode session..we used magic ajax for our application asp.net 1.1 .after porting it to asp.net 2.0 ..problem comes ,in asp.net 2.0 magic ajax only support nostore mode.our code is based on session mode...thanks
hai magic ajax for asp.net 2.0 is not supporting page store mode session.. we used magic ajax for our application asp.net 1.1 . after porting it to asp.net 2.0 ..problem comes ,in asp.net 2.0 magic ajax only support nostore mode. our code is based on session mode... thanks

I started using Magic Ajax over a year a go just before "Atlas" (now called MS Ajax) came out. I have to say it was easy to get it to work but I started to problems with getting things like paging on gridviews to work. The problem with this was that I just couldn't get any help or support on the issue, so I switched to Atlas\MS Ajax and never looked back.

Go with MS Ajax, at least you are guaranteed upgrades and updates to it and fairly good support from the community and MS. And also loads of documentaion and examples on the web. Magic Ajax just cant compete with that and will eventually die out. You need to work with things that have a future and will be supported and upgraded. If you are building asp.net apps and want to use Ajax then you should use MS Ajax, there is no reason not to.


what about session mode in magic ajax in asp.net 2.0

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

Why Sys.WebForms.PageRequestManager only with UpdatePanel?

Why do I only get access to Sys.WebForms.PageRequestManager if I have an updatepanel in my page? I have some really good uses for this method, but right now I only get access to the object if I include an UpdatePanel in the page.

If I want to include this when I have my control in the page, what is the parameters needed to extract it from the resources using Page.ClientScript.GetWebResourceUrl ?

In the RTM version (due out by the end of this month), Sys.WebForms.PageRequestManager will be available even if you don't have an UpdatePanel on the page. In the mean time, I recommend just putting an empty one on the page: <asp:UpdatePanel runat="server" />.


Perfect !

Wow - glad I found this post, that was going to be a long, painful and probably fruitless debug session otherwise. Thanks for that!

PS. Anyone know *why* this is the case?

Why Sys.Application does not work?

I just begin to learn ASP.NET AJAX. I have a simple question, please bear with me. I want to test client-side page life cycle. Here is my code. I don't know why pageInit does not get called? But pageUnload works.

Thanks a lot!

<head runat="server">
<title>Untitled Page</title>

<script type="text/javascript">
<!--
Sys.Application.add_init(pageInit);


function pageInit()
{
alert("Enter init page.");
}


function pageUnload()
{
alert("Page unloaded!");
}
//-->
</script>
</head>
<body>
<form id="form1" runat="server">

.....

Try putting your Sys.Application.add_init(pageInit) *after* you've defined your pageInit function.


I think I got a error that Sys is undefined. Did I miss including any namespace?

Thanks again!


The problem is fixed. I need to move <script> section after <asp:ScriptManager ID="ScriptManager1" runat="server" />, so that Sys can get reference.


I expierence the same problem, IE7 throws a javascript error "sys is undefined".

I did like you described and put the <asp:ScriptManager> section before my first <script> tag, but it doesn't help.

Have to put the ScriptManager section into my masterpage aspx file because of the <form> tag, could this be the problem?
In the browser output file of my aspx there are still <script> tags above the ScriptManager.

What can I do on this?


Check out this post for ideas about why you might get "sys is undefined":http://weblogs.asp.net/chrisri/archive/2007/02/02/demystifying-sys-is-undefined.aspx.

I guess it probably is the web configuration issue. Create a new AJAX-based web project, copy its web.config to your project to see if it works.

Why templating the content of the UpdatePanel?

Many ASP controls use template for their content (theGridView being a good example). TheUpdatePanel has aContentTemplate property that, as the name suggests, contains the content of the UpdatePanel.

Yet, since the UpdatePanel is not a repeater control, I do not grasp (as a consumer of the ATLAS library) the interest of templating the content of the UpdatePanel. Does some has an idea why a ContentTemplate is used instead of the regular control children?

Thanks in advance,
Joannès
http://www.peoplewords.com

hello.

i'd say that a template let's you have complete control over the content of the updatepanel. if you had a property of another type, you'd only be able to use elements of that type (or of a derived type)


ThePlaceHolder is not templated and but can include any element (as long as they inheritControl which is not a real constraint). My question can maybe be rephrased as "Why did the UpdatePanel not follow the PlaceHolder design pattern?".

Joannès

hum...how about designer integration? i'm not sure because i really don't use the designer, but can you drag-n-drop controls from the toolbox into a placeholder control?

Why the value always is false?

Following is my codes. No matter I login or not,the userLoggedIn always be false. Why?

<%@dotnet.itags.org. Page Language="C#" AutoEventWireup="true" Codebehind="WebFormTest.aspx.cs" Inherits="EdtungWeb.WebFormTest" %><!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 language="javascript" type="text/javascript">
// <!CDATA[ function Test() { debugger var userLoggedIn = Sys.Services.AuthenticationService.get_isLoggedIn(); } // ]]> </script
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
</div>
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="Test()" />
<asp:Login ID="Login1" runat="server">
</asp:Login>
<asp:LoginStatus ID="LoginStatus1" runat="server" />
</form>
</body>
</html>

and the loginstatus is retrieving the right information?


Yes, it is, the loginstatus is retrieving the rightinformation.

Many thanks for your replying.

Unless you use the AuthenticationService to Login the user it will remain false. One hack might be to inject the following line in your pages from the server side when you are sure the user is logged in.
Sys.Services.AuthenticationService._authenticated = true;

I see.

Many thanks for your replying.


Would you mind marking that as answer.

Sorry for that.

Many thanks for your remind.

Why The Toolkit DLL is much bigger than download

I download the Version 1.0.10301.0 Ajax Control Toolkit. Both of With Source code and without .I found a question.The ajax control toolkit dll file which is in the without source code package is 764KB(in "\SampleWebSite\Bin" ),but the dll file I generated from the source code is near 1.3MB. Why?

if you compiled in Debug mode, then your assembly would be larger than if you had compiled in Release mode.


oh~~~~~~~~ Right! Thanks for your help answer!

Why there is no *.aspx.designer.vb files in Visual studio 2005?

On my computer windows XP, I use visual studio 2005 for development. I create a atlas project for my work.

Everytime when I create a new aspx or ascx file, there is no *.aspx.designer.vb file. But on some other computers(same environment), when create a new webform, VS will gerenate 3 files:

*.aspx, *.aspx.vb., *.aspx.designer.vb

Why? any settings related to this issue?

Hi,

the *.aspx.vb will not generate if you unselect checkbox "Place code in separate file" when you create a web form.

hope can help you.


Thanks for you reply. I knew that.

But I am not taliking about *.aspx.vb, I am talking about *.aspx.designer.vb

This *.aspx.designer.vb will hold all control variables declared in page *.aspx


Hi,

The computer where you can see the aspx.designer.vb file has the addin "Visual Studio 2005 Web Application Projects" available athttp://msdn.microsoft.com/asp.net/reference/infrastructure/wap/default.aspx. Be aware that by installing the addin you do loose some feature at the moment like "profile", there is a work around available also, check the code project to get the addon.

Hope this helps you.

PS: I hope that microsoft changes there mind on the designer files, i love partial classes but i do not like loosing view of the main class.

VBS1


Thanks.

So if aspx.designer.vb is invisible on my computer under a wep application inside a solution, anyway can find out this aspx.designer.vb file for webform?

Why this code does not work when its button is inside the AJAX “UpdatePanel” control ?

protectedvoid DownlFile_Click(object sender,EventArgs e)

{

string web_path ="./ items/part1.pdf";

string path = Server.MapPath(web_path);

FileStream MyFileStream =

newFileStream(path,FileMode.Open);

long FileSize;

FileSize = MyFileStream.Length;

byte[] Buffer =newbyte[(int)FileSize];

MyFileStream.Read(Buffer, 0, (int)MyFileStream.Length);

MyFileStream.Close();

Response.ContentType ="application/pdf";

Response.AddHeader

("content-disposition","attachment; filename=part1.pdf");

Response.BinaryWrite(Buffer);

}

Hi paradise_wolf,

You can't use Response.Write in a AsyncPostback trigger event of an UpdatePanel. You need move the button outside the UpdatePanel or register it as Postback trigger.

Hope this helps,


Hispvlong

I am not sure if "RegisterAsyncPostBackControl" registers the button asPostback triggeras you suggested to do. I am getting this error message:

"Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed.

Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.

Details: Error parsing near '%PDF-1.3%□□3389 0'."

Below is the relevant ASP.NET web form code and the added C# code:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

protectedvoid Page_Load(object sender,EventArgs e)

{

ScriptManager1.RegisterAsyncPostBackControl(DownlFile);

..

}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

<asp:UpdatePanelID="ITEMS_LIST_EREADER_PANEL" runat="server"

UpdateMode="Conditional">

<ContentTemplate>

..

<asp:ButtonID="EreaderBtn"runat="server"Text="Next"

OnClick="EreaderBtn_Click"/>

..

</ContentTemplate>

</asp:UpdatePanel>

<asp:UpdatePanelID="DOWNLOAD_PANEL"UpdateMode="Conditional"

runat="server">

<ContentTemplate>

..

<tableID="DownloadDialogTb"visible="false"runat="server">

<tr>

<tdalign="center">

<asp:ButtonID="DownlFile"runat="server"Text="Download"

OnClick="DownlFile_Click"/>

</td>

</tr>

</table>

..

</ContentTemplate>

<Triggers>

<asp:AsyncPostBackTriggerControlId="EreaderBtn"

EventName="Click"/>

</Triggers>

</asp:UpdatePanel>


Hi paradise_wolf,

You should use RegisterPostBackControl method to register a control as Postback trigger.

Hope this helps,


Thank you very much,spvlong . Big Smile

hi,

I am also getting same problem while generating PDF? i could not solver even after registring as postback trigger control. It gives me the same error.

If you have solved it, plz suggest the solution for the same.

thanks

Varsha


http://forums.asp.net/1662626/ShowThread.aspx#1662626

Why this doesnt work :(

Hi

I'm trying to create an calendarextender programmatically but it doesn't work :(

here is the code:

scriptManager =newScriptManager();

dateTimeMaskedTextBox =newTextBox();

dateTimeMaskedTextBox.ID ="DateTimer";

dateTimePicker =newImage();dateTimePicker.ID ="dateTimePicker";

dateTimePicker.ImageUrl =@dotnet.itags.org."~/icons/Calendar_scheduleHS.png";

calendar =newCalendarExtender();

calendar.TargetControlID ="DateTimer";

calendar.FirstDayOfWeek =FirstDayOfWeek.Monday;calendar.Format ="dd/MM/yyyy";

calendar.PopupButtonID = dateTimePicker.ID;

what's wrong with this???????

thanks.

you never actually add the control to the form. creating them in the code doesnt mean they are on the form. To add a control to a form programatically you do something like this.

Form1.Controls.Add(calendar);

so make sure you add your script manager, datetimepicker, datetimemasked box and calendar to the form you want it in


hmmmmmmmmSurprise

thanks a lot

I thought that calendar (CalendarExtender) it's not neccessary to be added on the form.

thanks in advance.

why Timer always reload updatepanel, is it right?

I tried to use timer to reload updatepanel, code like this

<atlas:TimerControl runat="server" ID="timer" Interval="5000"/>

<atlas:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
my controls...

</ContentTemplate>
</atlas:UpdatePanel>

right, I don't define trigger there. But even with code like that, the updatepanel still reload every 5 seconds, why it works this way?

thanks

I think I have found answer.

hello.

well, as you might have guesses by know, you have to set the mode property of the panel to conditional.

Why to use asp.net ajax

Anthem.net is so simple to use on doesnot even have to write a line of code.

Why should we consider using msft asp.net ajax instead of anthem.net ?

thanks

Because ASP.NET Ajax is part of the .Net framework, so you are assured of support, documentation and continued development (and a huge and growing amount of tutorials etc from users). That can never be said of Anthem.Net. What happens if the creator just gets bored with it one day?


do we have to write lines of javascript code with asp.net ajax version?

Thanks for your help


No you don't have to. You can use its basic functionality without writing one line of code. You can also use all the extenders in the control toolkit without writing any javascript. However, you can also customise the behaviours as much as you want by adding some javascript. Watch some of theAjax videos here

Why use Asp.Net Ajax

I am debating between using Asp.Net Ajax and "regular" Ajax. As of now I have used Ajax by writing the javascript files and the web service/web pages that does the XmlHttpRequest.

So my question is what benefit would I get from using Asp.Net Ajax.

For the most part, AJAX is AJAX. ASP.NET would be your deciding factor, over a different technology. But if you're currently using ASP.NET and creating the AJAX functions by hand, the toolkit will alleviate the need for hand coding.

Jeff


How does the toolkit render the page, if I add some Asp.Net Ajax tools to an already existing Asp.Net page will my viewstate get bigger, will Microsoft add some code to the page to make it work that I don't know about.

ASP.NET AJAX - it's easy, quick and it's fun. :)

You can use notepad to write your .NET application, but you can use the Visual Studio ...

You can do AJAX functionality by hand, but you can use ASP.NET AJAX...


with asp.net you pass beyonde web pages u build web applications wth easy use of ADO.NET and so on... I would suggest you to try asp.net.. enjoy exploring cause this is basicliy what I'm doing...


It's a good question.

The thing is ASP.NET AJAX gives you all these things with a Microsoft Support team behind it:

1) Client side AJAX API - probably much like the one you've written but almost certainly far, far bigger. It can also call SOAP Web Services, Static aspx Page methods, serialize and deserialize objects and supports "classical class inheritance" with interfaces. It's a pretty good client side API and has had some very clever people develop it. The CTP also has a taster of even more ambitious Client APIs like XmlScript, DataTables and DataSources. Its not perfect by any means but I understand the next version of Visual Studio will include full Javascript intellisense for it which could be very cool indeed - especially if it alo makes it into the Express versions of that product (which I would expect it to).

2) Server Side API - Based around the Script Manager and UpdatePanels mostly. Update Panels are rediculously easy to use although FAR from optimal AJAX but have the huge benefit of "degrading" to a normal postback if Javascript is disabled. Conversely, the Bandwidth used for SOAP WebMethods could hardly *BE* more optimal, using pure Json up and down the pipe - fantastic value for money!!

3) Client Server integration: easily pass objects from client to server and back again.

4) Ajax Control toolkit - a set of Widgets to easily add cross browser GUI controls that take advantage of AJAX

5) Provides a defined Ajax Framework which is backed by microsoft, something non of the other frameworks can offer. The more popular ASP.NET AJAX becomes, the more community it gets and the better it gets. Dojo, Prototype, Bindows are all great but will always remain a little marginalised by something like ASP.NET AJAX.

6) This community and others like it.

I think it's fair to say that given where ASP.NET 2 used to be, with its postback architecture to where it is now (with ASP.NET AJAX) I think is a great improvement indeed, just the act of popping an update panel on an existing ASP.NET page can transform it from being humdrum and ordinary to something with much greater response and even "Wow" factor as it will only do a partial render (less bandwidth), there is no flicker (as the page does not get discarded) and the page scroll position does not need to be affected. 100% better already.

I would also say that although much of it comes across as "Ajax for dummies" (although you could also say that about the other Ajax frameworks out there) I think there is plenty of scope there also to create nice, optimal interfaces, additional toolkit widgets and other reusable AJAX enabled objects but the real key is the support and the continued development by some very, very talented people. Fundamentally I think the "ASP.NET" thing gets in the way of the "AJAX" thing and can make things far more complex than they need to be but ultimately, if you are using Visual Studio (full or express) and are creating Web Applications or dynamic sites then ASP.NET AJAX is the way to go.

Or to put i another way, what do you think will get you your next job in a programming team, saying you've written this killer AJAX framework and use it all the time and it "works great form me", or saying that you have mastered the "industry standard" AJAX toolkit and can leverage the knowledge therein, and which may well be the AJAX toolkit your next employer is already using? Trust me when I say I was in that position offering the former, I showed them my widgets, my treeview, my resizer bars, my fake windows, my serialization objects, my lazy loading, my drag and drop, my menuing system, my eventing system, my animation system, even my 2D and 3D graphics engine, all pure javascript and all built in - yes I got the job but had to promise to learn ASP.NET AJAX straight away if I wanted to do that kindof thing (ie: it's industry standard and the other developers can then work on my code, ie I remain dispensible, which is what they want).


Just the answer I was looking for.

VR2 you said:

"yes I got the job but had to promise to learn ASP.NET AJAX straight away if I wanted to do that kindof thing"

For you to learn straight away what books/websites, if any, did you use to move from your old way of writing ajax apps to Asp.net Ajax?


Another question:

Is there any speed difference when using Asp.Net Ajax compared to other Ajax Frameworks, and does anyone know if search engines look at the pages differently.


You can start from

http://ajax.asp.net/docs/

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


"For you to learn straight away what books/websites, if any, did you use to move from your old way of writing ajax apps to Asp.net Ajax?"

I got a book called "Programming Atlas" which I nearly threw out in disgust until I was told that the stuff it talks about still exists but in the CTP (and in a modified form). Also this website has been invaluable. I have to say though that I'm still just finding my feet not only with this but with ASP.NET also (I previously used COM, VB6, asp classic & javascript).

As to the speed of ASP.NET AJAX - I'd imagine that it depends what you are comparing it with and *how* you are doing it.

In general UpdatePanels will be slow and clunky (by comparison) but will offer extreme ease of use and a server based event architecture using the well established and frankly huge ASP.NET 2. And it will degrade for the mobiles etc!

Web Services and Static Page Methods will be fast and nimble but - what do you DO with the data once you have it? This is where you need a strong client side API (widgets) to display and allow the user to manipulate the data WITHOUT needing update panels to post back the viewstate every click (so that server events can fire and update the server version of the page DOM and send it all back again).

And this is where the CTP could come into play, just so long as you don't need to be able to downgrade for Mobile Phones! For example, I did an experiment using the CTP client side DataSource and DataTable - and a server side DataService or WebService (wrapping calls to a TableAdapter) where you could simply instatiate these objects on the client and have a grid that was effectively 2 way databound to the datasource, meaning that the user could update any data in the grid they wanted and the DataSource would post only the changes back to the server using JSON. The custom grid object tool a while to write as an extender in the AjaxToolkit but once written, in 2 minutes you could have this up and running and it was as optimal as you like.

why using Application Services?

Hi!

Why using Application Services?, I want put my login control in updatePanel?

Which is better?

Saludos,

Both is correct, this is what they call Client Side Model vs Server Side Model :-)


Oh, only that, Thanks :).

Saludos,

Why web robots cant request aspx pages in Ajax project ?

When Icreate aspx pages in Ajaxproject googlebot, yahoo-slurp and other crawlers can’t see these pages.

I’vecreated two test sites to show the problem:

Pagewithout Ajax:http://test.cky.pl/noajax/Default.aspx

Page with Ajax:http://test.cky.pl/ajax/Default.aspx

In browserI can see both of these pages. But when I try to saw what web robot can seewhen it requests my page (I was using this page and other tools (result wasthis same):http://www.smart-it-consulting.com/internet/google/googlebot-spoofer/index.htm

For Ajax page I was gettingerror massage:Invalid URL or serverdoes not respond, HTTP return code: 500

For normalaspx page everything is ok.

If someone couldshow me solution for this problem and could explain me why robots can’t requestAjax pages Iwould be very thankful.

Have you found a solution for this yet? I also noticed the same problem. If you point the W3C link validator at an AJAX site, it just says HTTP 500 internal server error. You get the same problem if you use an link checking package such as Xenu. If you view the page in your browser, it's fine.

This concerns me as I'm heavily involved in SEO - will Googlebot see the same and not index the site...


OK, found a workaround. Add this to Page.Init:

if (Request.Browser.Crawler ==true || Request.Browser.W3CDomVersion.ToString() !="1.0" || Request.Browser.Type.ToString().Contains("Opera")){ ScriptManager1.EnablePartialRendering =false;}else{ ScriptManager1.EnablePartialRendering =true;}

Thanks a lot, it's helps.

Why webservices?

I don't know if I haven't understood the right way to use Atlas, but as far as I know all the calls are done to a webservice? How is this helpful? Why does it have to be this way? Why not call methods defined in the asp page?

Thanks for the help

Atlas lets you call both methods on Web Services and methods defined on the page. Using a Web Service is cleaner if you want to make some general functionality available to multiple pages, but there are also scenarios where calling methods on the page is convenient.

David


Well, I guess whatever you need to do the job is what you'd choose. Atlas streams XML based information to and from the server - thereby making webservices a perfect fit. By your statement "calls methods in the page", I suppose you are referring to server side calls... In this case, postbacks are no longer required - Web 2.0 is coming, where a richer UI experience can be achieved by asynchronously updating the bits of data on a screen that are needed - not the entire page for the sake of postbacks. IMHO, Atlas is a great step forward for SOA and SaaS...

Jon


Hello,
I am not getting how can i make the script part dynamic...
In detail...i want to show a Chart image when user hovers over a stocksymbol(ex.TCS or MSFT) but there can be many such symbols on the page,(another solution is that i add <script></script> for eachsymbol at client side...but its obviously not feasible) so how can imake the <script></script> part of our Client dyanamic...

hope u can help
Devang

Why were the UpdatePanel-compatibile validators removed

Why were the UpdatePanel-compatible validators removed from the RTM build? This seems like it is going to create a lot of headaches!

The plan appear to be to an update of System.Web from windows update.

http://blogs.msdn.com/mattgi/archive/2007/01/23/asp-net-ajax-validators.aspx

Why XmlHTTP?

Have we looked at standard DHTML alternatives to XmlHTTP? I've never used it in my AJAX apps because of browser compatibility and security dialogs cross-domain. I understand using it to connect to non-Atlas web services, but an Atlas client to Atlas web service could asychronously request data post-page load by requesting script - e.g. I could call the web service like "myservice.asmx/js?param1=foo¶m2=bar".

You are right that XmlHTTP can have browser compatibility issues, which is why a client framework like Atlas is useful. When you use Atlas, you never directly use XmlHTTP. Instead, you use Atlas abstractions built on top of it that have the necessary logic to make it work in most browsers.
I'm not sure I understand the alternative that you're suggesting. Another method that is sometimes used it to make the request into a (hidden) iframe, and get the data from there. Is that what you are referring to? Note that doing this will hit the same cross-domain limitations as using XmlHTTP (this is by design for security reasons).
David

Thanks, I understand the user doesn't use XmlHTTP directly. But the underlying layers use it exclusively (at least from my cursory examination of AtlasCore.js), limiting the browser support.
Yes, that is the technique I am referring to. It does not have cross-domain limititations (there's no reason I can't include a script from another domain - by placing the reference in my page, I am allowing that script to run in my domain). If you're interested I can point you to a live demo application on one domain requesting data from another domain (asynchronously, post-page load, no-xmlhttp).
Jim


Hi Jim,
If a page has an iframe, it can navigate that iframe to any URL. However, it cannot access the data inside that frame unless it lives in the same domain, due to cross frame scripting restrictions:
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/om/xframe_scripting_security.asp
But maybe your are talking about something different?
thanks,
David
Does XmlHTTP restrict us to REST-style interactions with all the pre-knowlege that requires or can we use XmlHTTP for compositional discoverable SOAP? If so, I can easily imagine AJAX style pages that will need to pull data from many many sites. Imagine, for example, an enterprise window to embedded control systems accessible by SOAP such as available from
BACnet under BACnet-XML
LON using iLON 100
Tridium using the new Niagra framework
In each of these cases you are discussing a single interface pointing to multiple exposed data sources. Lets move the bar higher, then, to also pull vector XML (say SVG) from some sort of drawing room
If I have all these sources in my trusted sites, why shouldn't I be able to cross-script across them?
Hello.
I'm a much interesting in your live demo. If it possible can you send it to me at mrorbit [at] pochta.ru.
Thank you in advance.
Another method I have used is loading a script with an IE:DOWNLOAD-control and call it.
http://searchpalette.com/g/g.html
This method will work with different site, I think. Also, I believe it works on a few browsers. To incorporate this int the ASP-world might not be worth it though.
If there is any interest, I could give it a try.
Gorm Braarvig

Why?

Why is it that the example below works just fine, but if I move the updatepanel anywhere else, it stops working? It won't work if I put it directly below the asp:Panel. It won't work if I put it inside the <table>... Is there some rule I should be following here for where an updatepanel should be placed?

<asp:Panel ID="pnlOptions2" runat="server"> <tr> <td valign="top"><strong>Additional Options</strong></td> <td colspan="2"> <asp:UpdatePanel ID="upOptions2" runat="Server"> <ContentTemplate> <table cellpadding="0" cellspacing="0" width="650"> <tr> <td width="175"><asp:CheckBox ID="cbTransparencies" runat="server" Checked="false" AutoPostBack="true" />Transparencies</td> <td width="125"><asp:CheckBox ID="cbLetter" runat="server" checked="false" AutoPostBack="true" />Letter</td> <td width="175"><asp:CheckBox ID="cb11x171" runat="server" checked="false" AutoPostBack="true" />11x17 1's</td> <td width="175"><asp:CheckBox ID="cbPaper" runat="Server" checked="false" AutoPostBack="true" />Provided Paper</td> </tr> <tr> <td><asp:CheckBox ID="cbNCR2" runat="Server" checked="false" AutoPostBack="true" />2 part NCR</td> <td><asp:CheckBox ID="cbLabels" runat="server" checked="false" AutoPostBack="true" />Labels</td> <td><asp:CheckBox ID="cb11x172" runat="server" checked="false" AutoPostBack="true" />11x17 2's</td> <td><asp:CheckBox ID="cbLaminate" runat="server" checked="false" AutoPostBack="true" />Laminate</td> </tr> <tr> <td><asp:CheckBox ID="cbNCR3" runat="Server" checked="false" AutoPostBack="true" />3 part NCR</td> <td><asp:CheckBox ID="cbTabs" runat="server" checked="false" AutoPostBack="true" />Tabs</td> <td><asp:CheckBox ID="cbCards" runat="server" checked="false" AutoPostBack="true" />Business Cards</td> </tr> <tr> <td><asp:CheckBox ID="cbNCR4" runat="Server" checked="false" AutoPostBack="true" />4 part NCR</td> <td><asp:CheckBox ID="cbCerts" runat="server" checked="false" AutoPostBack="true" />Certs</td> <td><asp:CheckBox ID="cbBrochures" runat="server" checked="false" AutoPostBack="true" />Brochures</td> </tr> </table> </ContentTemplate> </asp:UpdatePanel> </td> </tr> </asp:Panel>

The UpdatePanel prefer to work within a DIV or a SPAN object. Try setting the RenderMode property of the UpdatePanel toInline


See it here for RenderMode property, try to set it

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

See for most common problem of UpdatePanel

http://blogs.visoftinc.com/archive/2007/09/23/asp.net-ajax--updatepanel-not-working--common-problems.aspx

Width of HoverMenu Grows Each Time it is Passed Over

The Width of HoverMenu Grows Each Time it is Passed Over is this a bug or am i missing something. this can be seen by visiting my site and hover over the quick links url. I will not post my url in this since some may think i'm advertising but my url can be seen in my user profile. each time the mouse hover over the url panel or hovermenu expands.

Thanks.

The Padding Attribute cause the width of the HoverMenu expand on each hover of the mouse I have removed the padding from style sheet that is attached to the Panel control an seemed to have fixed my problem...

Sean

Wierd behavior with the ratings control

I noticed that the hyperlink on the stars within the ratings control points to "#". On the samples page it works fine, however, on my page, when you rate, the page gets anchored to the top.

What is the reason for this problem? I have set the EnableAutoPostBack propery to false, so that is not an issue here. The page does not refresh(there is no postback), but the page anchors to the top.Any tips?

Thanx.

Premal.

Hi Premal,

Would you please provide asimple repro and youAjax Control Toolkit's Version? Without these, I'm afraid that we cannot figure out the exact root cause.

Best regards,

Jonathan


What is simple repro?

Premal.

wierd behavior on submit button (partial postback acting as full postback randomly)

I setup this example from here, but I am getting some weird behaviour.

First off I was getting the pretty famous popup error of "unknown error" I was able to fix this by adding

<xhtmlConformancemode="Transitional"/>

to the web.config.

Right now the weird error that I am experiencing however is when I do a partial postback, the button actually does a full postback the first time, then after that it turns to partial post backs. This behaviour isn't always consistent, sometimes it takes 10 postbacks before it starts working as a proper AJAX partial postback.

Doesn't make any sense to me ?

Any one got an idea on this one? I copied the source directly from here, its very straightforward.

article

I have the same behavior. But I think in my case it is because I'm running vista RC1

If I clear my temporary internet files it seems to work ok for a while tho


I'm still running windows 2000 and its messing up, so I don't think it has anything to do with that.


At first clearing temp files seemed to help, but now it doesn't. It's so erratic that I can't come up with any possible ideas right now.

Anyone else experiencing this?

Thanks,

mike123

Wierd Error if page is left alone for too long... (ajax pages)

I have a wierd error that only occours if there has been no interaction with the webserver for too long. (over 30 mins)

The specific error that is returned is

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

This seems to happen to any page that has a script manager and update panel in it. I have tried adjusting the session timeout period, but this doesn't seem to help. It is almost like the page is loosing it's reference to the script files required by the ScriptManager. Is there some caching parameter I could add to the page to extend the cache time?

Any other ideas are welcome. This is a strange one. So far the workaround is to add a timer to the page that just keeps it alive.. (updates the page every minute or so with a meaningless value...)

TIA

Rob

See:http://forums.asp.net/p/1134743/1809108.aspx#1809108

-Damien


Hi,

Please see this post:504 Gateway Timeout occuring for very small number of users

504 Gateway Timeout
The server, while acting as a gateway or proxy, did not receive a timely response from the upstream server it accessed in attempting to complete the request.

Best Regards

Wiki Januari/Februari CTP question

Downloaded the latest bits of the Wiki but was unable to attach the needed database files to my SQL Server 2005.I can't run SQL Express beside SQL Server for some stupid reason so I'm missing the .ldf files in order to be able to get the project going.

Can these .ldf files be retrieved somehow or is there some other procedure that I can use to get the .mdf files attached?

Or even better can someone explain me why I can see SQL Express in the SQL Server Managament Studio and play with it but when I want to view the databases in my App_Data subfolder in VS.NET 2005 I'm unable to get access to it... Error message always gives me this:

Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed.

Also when I just want to run an application by hitting F5 I get this message.

Thanks in advance!Anyone?

Hi,

I already provided an answer toyour post that pointed to this one. You can use the

sp_attach_single_file_db command to get it to work.

Grz, Kris.