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

Wednesday, March 28, 2012

PageMethods

Hi,

I ama developing web application using ASP.NET, and I use atlas framework in my app. I have a problem with using PageMethods, I want to return value which came from page to another javascript but I can not,

Normal Page Method usage

function sayHelloFromPage() {

PageMethods.HelloWorld('Mehmet',onComplete);

}

function onComplete(result) {

}

what I wantto make it

functioncallSayHelloFromPage() {

var Result = sayHelloFromPage();

}

function sayHelloFromPage() {

PageMethods.HelloWorld('Mehmet',onComplete);

}

function onComplete(result) {

return result;

}

Hi

PageMethods.HelloWorld('Mehmet',onComplete);

The above call happens asynchronously, which means the call is send to the server and the client does not wait for the call to complete; therefore, you don't see the results immediately instead you have to get the results in the onComplete event, which is fired when the call completes.

Whatever you want to do with the results, e.g. change an HTML element, you have to do it in the onComplete function.

PageMethod vs WebSerivce/ServiceMethod

I've seen people say that we shouldn't use PageMethods and should stick with using web services as is currently written, however, I've not seen a reason why. My situation right now is that I want to combine the HoverMenuExtender and DynamicPopulateExtender to display a preview of an item for my gridview. However, my site uses forms authentication, and if I try to pull the html (screen grab) from the page, I just get the forms login page. So I'm curious as to why I shouldn't use a page method which wouldn't have the authentication problem. We already have a webservice running, and I'd rather use that webservice, but since it seems like I can't - I'd rather use a page method then start another webservice.Surely someone has an opinionWink
Surely someone has an opinionWink
Performance would come to mind. A page method requires an (almost) complete run through the page life cycle. Only the render phase is scipt.
Hi,

a page method doesn't require a full run through the page lifecycle. For this reason it is the preferred alternative to a partial postback, where the page goes through all its lifecycle.

Also, in a partial postback, even if only the html for the controls to update is sent in the response, all the web controls are actually rendering their content (but they do it writing into a NullTextWriter).
PageMethod:
I and the IL code disagree. The ScriptModule Registers the PageServiceHandler which in turn sets a RenderMethodDelegate. Therefor, the page runs up unitl the Render method like it would normally. -> Less performance than a WebService call.

Thanks for the heads up on the UpdatePanel. Checked out the IL Code and there it is (the RenderMethodDelegate) in hte ScriptManager.
Hi,

apologies for the confusion I made in my last post, you're perfectly right.

However, my opinion is that the choice between a page method and a web service should be driven by the particular scenario (the data to expose, the need for the elaboration to access the controls on the page) and not by performance.

PageMethod Timeout

Hi

I call a web method exposed in an aspx page as follows:

PageMethods.MyWS("hello world",
OnCallbackComplete,
OnCallbackTimeout,
OnCallbackError,
null,
10); // timeoutInterval

To simulate the timeout I add some sleep time to the thread in the web method, lets say 10000 (10 seconds). Problem is the timeout callback method on the client doesn't get invoked.

Any ideas?

CraigThere was a bug where we weren't respecting the timeoutInterval set onthe request if the default timeout interval is set. Can you checkif you have set the WebRequestManager's timeout interval? Trysetting the WebRequestManager's timeout interval and see if thattriggers the timeout callback...

Hope that helps,
-Hao

Thanks for the reply.

I tried the following which didn't trigger the timeout as expected:

Sys.Net._WebRequestManager._timeoutInterval = 10;

Sys.Net._WebRequestManager.timeoutInterval = 10;

Sys.Net._WebRequestManager.set_timeoutInterval(10); // threw an exception

PageMethods.MyWS("hello world",
OnCallbackComplete,
OnCallbackTimeout,
OnCallbackError);
So that's not quite right, the instance you want to use is the static Sys.Net.WebRequestManager, rather than the _ one.

So you can do Sys.Net.WebRequestManager.set_timeoutInterval(10), or in the xml markup, you can do something like

<script type="text/xml-script">
<page xmlns:script="http://schemas.microsoft.com/xml-script/2005">
<components>
<webRequestManager timeoutInterval="3000"/>
</components>
</page>
</script
Hope that helps,
-Hao

that did the trickBig Smile [:D]

thanks

PageMethod Static Ajax WebService and User Controls

I have a page HostPage.aspx, which is a generic hostpage that will dynamically load Web User Controls at runtime, according to the needs of various other users. Those other Web User Controls will be created by the other users, such that they can put anything they like in that Web User Control, and it will be dynamically populated and put in the HostPage.aspx. They will always use HostPage.aspx, they cannot edit it. This is working as-is, and everything is great.

Now, some users want to put AJAX functionality in their User Controls, such that the HostPage.aspx will contain their User Control, the User Control will contain an UpdatePanel, a ScriptManager, etc.

To enable page methods, we have to set the EnablePageMethods="true" on the scriptmanager, and have to declare a static method *somewhere*. The requirements are such that we cannot be declaring these static methods in the HostPage.aspx, because it cannot know what the controls, and therefore static methods, are until runtime. On the other hand, if we declare these static methods in the User Control, it's not defined in the HostPage, and AJAX PageMethod callbacks fail ("Method myMethod is not defined"), because the page doesn't know of it's existence.

1. Has anyone tried to do something similar to this, namely having AJAX controls in a User Control, which is hosted in a page, yet also needs to use the Page Methods, yet cannot declare them in the page (I know, that's pretty specific).

2. Any ideas on how this might be accomplished?

I'm thinking of using Reflection or DynamicMethod (http://msdn2.microsoft.com/en-us/library/system.reflection.emit.dynamicmethod.aspx) to make this happen, such that at runtime, the page will examine its child controls for any static methods with the ScriptService attribute, and then dynamically create a static method on itself with the same name, calling the child, but that is rather involved and I fear the performance risk of this (if this whole idea is even possible). Plus, the generated method wouldn't exist until after the controls exist, and I'm not sure where that falls in relation to the timing of the AJAX extensions (looking for the MethodName). It might be (probable) that the handler is looking for the method even before the controls are initialized, in which case that idea won't fly.

You can't do that... as described here (http://www.singingeels.com/Articles/Using_Page_Methods_in_ASPNET_AJAX.aspx) Page Methods are only on pages :)

But you can get what you want if you make your user control register a "web service" as in this article:http://www.singingeels.com/Articles/Consuming_Web_Services_With_ASPNET_AJAX.aspx

If your users aren't able to add webserivces (I really don't know the situation your building)... then they can register a regular old "AsyncPostBack" and wire it up themselves (sorry, no article on that yet).


Right, I understand completely the concept of PageMethods, that they are on pages, etc. That's why this is a bit of a tricky spot.

I guess what I'm looking for is whether anyone has come up with anything clever to get around this situation (PageMethods from a Usercontrol). The usersare free to create and consume their own webservices, if they like, but if possible, I would like to give them this functionality for this situation.


OK, I believe it's Page.ClientScript.RegisterAsyncPostBack or maybe ScriptManager.RegisterAsycnPostBack ( I can't remember )... either way, it'll post back to the page... and ultimately the user control, and fire an event (on the user control).

That'll work just like the page methods... (a little better actually for what you're doing)

PageMethods call from user controls (ascx)

Hello,

i am looking for a way to call webmethods defined in an (ascx) user control (not a web form page aspx) using PageMethods.{MethodName}. For now, i only get a javascript error saying that PageMethods is not defined. Is there a different syntax to acces thos methods or is it just not possible ?

Thank you for your help

thomas

Any answer would be appreciated.

Thank you

thomas


hello.

currently, you can only call web service methods or page methods (and in this case, the methods must be static)

Monday, March 26, 2012

PageMethods is undefined

When using the July CTP, I was able to use the PageMethods defined in my web page with no problems.

After loading the beta 1.0 release, I get the error "PageMethods is undefined" when attempting to use WebMethods from my page.

The "Change from the CTP" docs mention that this has been changed to use static page methods and that it's supposed to be easier now. It would be very helpful to see a working sample using PageMethods in the most recent beta release.

Anyone have a working sample?

Ken

hello.

here's a quick test i've written

<%@. Page Language="C#" %>
<%@. Import namespace="LivroAtlas"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
[System.Web.Services.WebMethod]
public static Aluno[] ObtemAlunos()
{
Aluno[] alunos = new Aluno[]{
new Aluno( "João", 15 ),
new Aluno( "Rita", 16 ),
};

return alunos;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager runat="server" ID="manager" />
<input type="button" value="invocar método da página" onclick="handle()" />
</form>
<script type="text/javascript">
function handle()
{
PageMethods.ObtemAlunos( handleCallback);
}
function handleCallback( res )
{
for( var i = 0; i < res.length; i++ )
{
alert( res[i].Nome + "-" + res[i].Idade );
}
}
</script>
</body>
</html>


Thanks very much, Luis.

I had missed that page methods are now required to be static.

Ken


Could someone please bring back the old PageMethods, when it could access the page control's value, that was great.

hello.

use updatepanels for that and set the childrenastrigger to false so that you don't send back html to the client. there's no need to have pagemethods without them being static.can anyone provide a good scenario where non-static page methods are really the only way to go?


I'm actually using the PageMethod object so that when a user presses an image button, it calls a server side method that pulls values out of session state as well as control values and then makes a call to a back end software that does some processing for our application and returns an object that we then load into a treeview. However, you are not able to reference Session variables from static methods neither are you able to reference controls. This is my example...do you think i'm doing it wrong or do I have a valid scenario?

hello.

how about using an updatepanel or a web method? you do say that you need to refresh the UI...btw, i do think that you can access session state from a static method:

<%@. Page Language="C#" %
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
<script runat="server">
[System.Web.Services.WebMethod]
public static int O()
{
HttpContext ctx = HttpContext.Current;
ctx.Session["i"] = Convert.ToInt32(ctx.Session["i"]) + 1;
return Convert.ToInt32( ctx.Session["i"] );
}

protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);

if (!this.IsPostBack)
{
HttpContext ctx = HttpContext.Current;
ctx.Session["i"] = 0;
}
}
</script
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager runat="server" ID="manager" />
<div>
<input type="button" runat="server" id="bt" onclick="handleClick()" />
</div>
</form>
<script type="text/javascript">
function handleClick()
{
PageMethods.O(function(res){ alert( res ); });
}

</script>
</body>
</html>

that sample simple returns an int. maybe you can adapt it so that it returns what you need.


This is odd, but I can't seem to get PageMethods to call when the WebMethod is in a codefile. I didn't have a problem with that before. Any thoughts? The exact same code works fine if the WebMethod is part of C# embedded on the page in script tags as Luis has done. I really prefer it the way I had it before, as I prefer using codefiles.

"C#"-->"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> [System.Web.Services.WebMethod] public static string Test() { return "Success"; }</script><html xmlns="http://www.w3.org/1999/xhtml" >"Head1" runat="server"> "form1" runat="server"> "server" ID="manager"> "button"value="invocar método da página" onclick="handle()"> "text/javascript"> function handle() { PageMethods.Test(handleCallback); } function handleCallback( res ) { alert( res ); }

On the other hand, it doesn't work like this:

"C#" AutoEventWireup='false' CodeFile="Default.aspx.cs" Inherits="_Default"-->"-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >"Head1" runat="server"> "form1" runat="server"> "server" ID="manager"> "button"value="invocar método da página" onclick="handle()"> "text/javascript"> function handle() { PageMethods.Test(handleCallback); } function handleCallback( res ) { alert( res ); }using System;using System.Data;using System.Configuration;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;public partialclass _Default : System.Web.UI.Page {protected void Page_Load(object sender, EventArgs e) { } [System.Web.Services.WebMethod]public static string Test() {return"Success"; }} 

There is a bug in the beta build that prevents codebehind page methods from working, just incase requiring static methods weren't already going to make them useless enough..Wink... you have to include them in the aspx file if you want to use them...

See this post for more detailhttp://forums.asp.net/thread/1435443.aspx


hello.

jkolbo is right ony about one thing: there's a bug in the beta build and you can't put them in the code beahind file.

regarding the second part, i will not repeat myself and try to explain (once more) why the old instance page methods sucks...this time, i'll just say why the new static methods are good for. in previous releases, if you didn't want to use page methods due to the performance penalties associated with them, you'd have to use web services. static page methods lets you get the some thing without having to develop webservices


Hi,

Just because someone doesn't want to develop webservices is not a compelling reason to take away the functionalities of the old PageMethods. Performance was still better than a complete postback(which is what most of the internet is using). There should atleast be an alternative. Now we got 2 very similiar methods that do the same thing as oppose to 2 distinct methods that do different things.


Hello.

mnn888:

Performance was still better than a complete postback(which is what most of the internet is using). There should atleast be an alternative. Now we got 2 very similiar methods that do the same thing as oppose to 2 distinct methods that do different things.

this is the kind of thing to which i completely disagree! page methods had to send everything back to the server (ie, all the form's firlds, including hidden ones) and they only returned a value from the server. you don't need a postback to do this! if you need to send some values back to the server why not use javascript + web service method call or static page method call? they're a lot better that instance page methods!

if page methods updated the viwestate+control state, i'd be quite and i would be the 1st to say: bring them back. however, that didn't happened...so i'm not sure on where's the performance gain in using old page methods...can you see it?


One other thing to add. AutoEventWireup for the Page must be set to "true" or else the JS proxy is never generated.


hello.

as you can see by my previous sample, there's no need to have autoeventwireup set to true for gettig the proxy inserted on the client side. why?do?you?say?that?

Luis Abreu:

hello.

how about using an updatepanel or a web method? you do say that you need to refresh the UI...btw, i do think that you can access session state from a static method:

<%@. Page Language="C#" %
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
<script runat="server">
[System.Web.Services.WebMethod]
public static int O()
{
HttpContext ctx = HttpContext.Current;
ctx.Session["i"] = Convert.ToInt32(ctx.Session["i"]) + 1;
return Convert.ToInt32( ctx.Session["i"] );
}

protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);

if (!this.IsPostBack)
{
HttpContext ctx = HttpContext.Current;
ctx.Session["i"] = 0;
}
}
</script
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager runat="server" ID="manager" />
<div>
<input type="button" runat="server" id="bt" onclick="handleClick()" />
</div>
</form>
<script type="text/javascript">
function handleClick()
{
PageMethods.O(function(res){ alert( res ); });
}

</script>
</body>
</html>

that sample simple returns an int. maybe you can adapt it so that it returns what you need.

I'm a relative novice to ASP.Net AJAX, so please forgive me if i'm doing something blaringly obviously wrong here, but i copied and pasted the code shown above exactly, and when i press the button on the form, instead of the number "0" being displayed in the alert box, it is in actual fact displaying the entire html source of the page.

Any idea why this is happening?

PageMethods is Undefined

HI,

its Urgent

I am Getting Same Error Could u please Help me Out..

Here is My Code..

using System.Web.UI.HtmlControls;

using System.Web.Services;

using Microsoft.Web.Script.Services;

using Microsoft.Web.Script;

[WebMethod]publicvoid GetNewMessage()

{

string str ="Hello";

Response.Write(str);

}

Javascript

PageMethods.GetNewMessage();

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

<Scripts>

<asp:ScriptReferencepath="scripts.js"/>

</Scripts>

</asp:ScriptManager>

Thanks in Advance,

Suman...

Please its Urgent...

this is not sufficient to debug your error ... you need to show us the whole thing ... and what kind of error is that? JavaScript or server error?


check this post out ... same error as yours:http://forums.asp.net/t/993893.aspx


ScriptManager has to have EnablePageMethods=true and the WebMethod has to be static.


hi here is my full code..

aspx file

<bodystyle="margin: 0px;padding: 0px;">

<formrunat="server"action="RF_Message.aspx">

<divid="ContentPanel">

<divid="MessageList">

<asp:ScriptManagerID="ScriptManager1"runat="server"EnablePartialRendering="true"EnablePageMethods="true"EnableScriptGlobalization="true"EnableScriptLocalization="true">

<%--<Scripts>

<asp:ScriptReference Path="scripts.js" />

</Scripts>--%>

</asp:ScriptManager>

</div>

</div>

</form>

</body>

</html>

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

var str = PageMethods.GetNewMessage();

alert(str);

var result = document.createElement("div");var divlist = el("MessageList");

result.innerHTML = str;

divlist.appendChild(result);

function el(id)

{

return document.getElementById(id);

}

</script>

aspx.cs file..

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.Web.Services;

using System.Web.Script.Services;

using System.Web.Script;

publicpartialclassRF_Message : System.Web.UI.Page

{

//ChatManger Chatmanger = ChatManger.GetChatManager();

protectedvoid Page_Load(object sender,EventArgs e)

{

}

}

#region Script callback function

[System.Web.Services.WebMethod]

publicstaticstring GetNewMessage()

{

string str ="Hello";

return str;

}

#endregion

}

I am Getting Javascript Error While Running...

i am Getting alert Undefined...


RIght, you're executing that embedded script block as the page gets to it; pagemethods haven't been created yet (that happens during the clientside init, iirc. Try pulling all that code into your pageLoad() javascript function and see if that doens't help.

PageMethods quirk

So here's what I found while using PageMethods in Beta 2

    A server side method needs the attribute [System.Web.Services.WebMethod]A server side method should be static or else you'll get a PageMethods is undefined errorA server side method should NOT be defined in code behind but should be in the ASPX page in <script runat="server"> tag.Here's the quirk. A server side method CANNOT have two parameters with names that differ only in the case of their letters. eg. someParam and SomeParam, even if they are of different types, e.g. string and int This will result in a Sys.ArgumentTypeException with the message Object of type Number cannot be converted to type Function. Parameter name OnSuccess.
    <script runat="server"> [System.Web.Services.WebMethod] public static string SomeMethod(string someParam, int SomeParam) { return "Hello " + someParam + " you are " + SomeParam.ToString() + " years old"; } </script>
    <script type="text/javascript" language="javascript"> function CallMethod() { var age = 28; PageMethods.SomeMethod('MyName',age, OnCallResponse); } function OnCallResponse(arg) { alert(arg); } </script>
    Change the SomeParam to age and it will work.

So my question is : Is this a bug, quirk or by design? If a bug or quirk will it be fixed? Sure one NEVER names two parameters the same with just a change in the case but then again, NEVER say NEVER.

Thanks

I SO MUCH SUPPORT your finding #3. It's so stupid that the server side code won't work in code-behind but inline code would work. What the heck?

To any MSFT moderator:

Is there any workaround for #3? This is driving me crazy.


Weird, but I just tried to create a page just like yours and it works even if the static method is in the code behind...

This is the class:

public partialclass _Default : System.Web.UI.Page { [WebMethod]public static string GetServerDate() {return DateTime.Now.ToString(); }}


And this is the ASPX:

<%@. Page Language="C#" AutoEventWireup="true" CodeFile="~/Default.aspx.cs" Inherits="_Default" %><%@. Importnamespace="System.Web.Services"%>"-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml">Untitled Page"server"> "form1" runat="server" method="post"> "ScriptManager1" runat="server" />

"button"value="get date" onclick="GetDate();" id="Button1" />

"date" />

"text/javascript">function GetDate(){ var div = document.getElementById("date"); PageMethods.GetServerDate(function (result) { div.innerText = result; });}

Sorry about my last post which is unreadable...Angel

Reposted:

Weird, but I just tried to create a page just like yours and it works even if the static method is in the code behind...

This is the class:

public partialclass _Default : System.Web.UI.Page
{
[WebMethod]
public static string GetServerDate()
{
return DateTime.Now.ToString();
}
}


And this is the ASPX:

<%@. Page Language="C#" AutoEventWireup="true" CodeFile="~/Default.aspx.cs" Inherits="_Default" %><%@. Import namespace="System.Web.Services"%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server" method="post"> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <div> <input type="button" value="get date" onclick="GetDate();" id="Button1" /> <div id="date" /> </div> </form> </body></html><script type="text/javascript">function GetDate(){ var div = document.getElementById("date"); PageMethods.GetServerDate(function (result) { div.innerText = result; });}</script>

This looks a bug, thanks for reporting this issue, and it will be fixed in a future build.
-Hao


Hi,

that is not a bug. Remember that vbscript is case unsensitive.


Hi,

I tried the approach of using static methods for PageMethods in AJAX v1.0 Beta 2, but it is not working. The only change that happened is that the error message has changed from "PageMethods is undefined" to "PageMethods is null or not a object.

PLEASE HELP !!!!


Advance,

Where the heck is "vbscript" in whole picture? We are trying to access a WebMethod from Javascript using MS Ajax Beta 2 in the code-behind file.


I was hoping this would have been corrected in Beta 2. I guess I'll keep using the ATLAS CTP until this is resolved. Oh well, maybe in build 3??


hello.,

this is correct. the problem is related with the EnsureParameters of the WebServiceMethodData class. I don't know why, but it's "eating parameters" when they have the same name and differ only in case. here's the "bad" code:

privatevoidEnsureParameters()
{
if (this._parameterData ==null)
{
lock (this)
{
Dictionary<string,WebServiceParameterData>dictionary1 =newDictionary<string,WebServiceParameterData>(StringComparer.OrdinalIgnoreCase);
intnum1 =0;
foreach (ParameterInfoinfo1inthis._methodInfo.GetParameters())
{
dictionary1[info1.Name] =newWebServiceParameterData(info1,num1);
num1++;
}
this._parameterData =dictionary1;
}
}
}
 
I've tried reproducing this with a simple method and i get the 2 parameters and if i add them to a dictionary, i get 2 entries. this is not happening here (yes, i've used reeflection to reproduce what's going on and i can say that the dic only has one parameter.
if anyone have an idea on why is that, please,share with us!
thanks. 


hi.

dom't you hate it when you spend 1 hour looking at code and writing reflection just to see that the damn thing is right in front of you?:

newDictionary<string,WebServiceParameterData>(StringComparer.OrdinalIgnoreCase);
thanks Garbin!
 
 

Yeah, there are two places in the code that are using OrdinalIgnoreCase comparers which is what's causing the problem, removing the IgnoreCase for both dictionaries fixes the problem.

Hope that helps,
-Hao


hello.

does that mena that it'll be removed in the next release?


Yes I've already fixed it in the codebase.

Hope that helps,
-Hao

PageRequestManager : Whats the difference between doPostBack and _doCallBack ?

I want some parts of my web page refresh after a focus or changed event being made on a TextBox. What I want to acheive is get back to the server to do some code. I check the PageRequestManager and saw to way to make a postback to the server. What I want to do is get back to the server like I put a submit button without the whole page refresh. Some advices on that would be really appreciate !

It's not overly clear what your trying to do. Are you currently using UpdatePanels? If not, look into them:

http://www.asp.net/ajax/documentation/live/overview/UpdatePanelOverview.aspx

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

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


I know it's not clear. I'm sorry. I'll try to explain more clearly.

On a client event like OnFocus or OnBlur or OnChange, I'll check some client state for the input (TextBox) and take decision if I need to get back to the server to refresh some part of my menu. I try to implement a sort of contextual menu. So, when some part (say inside panel1) got focus, I want to make an ajax request to add some stuff to the menu. When the panel lost focus, maybe I'll switch the visibiliy of some parts of the menu on the client side or got back to the server to do some job.

I'm building a sort of UIManager. This Manager need to check some client state(hidden field) and decide to get back to server if I doesn't have all the state it need to add some part of the menu for the contextual part.

So, I put the menu inside and UpdatePanel UpdateMode=Always. When a control (maybe TextBox, RadioButton or panel) got focus, maybe I need to get back to the server. I want to know if it's necessary to put the control inside and Update Panel or I can write some code to submit the form and use eventArgument to know what I have to do...

I hope is it a little be more clear. I appreciate a lot the time you take to help me !


Hi,

Thank you for your post!

Based on my understanding, you just want to refresh the updatepanel via javascript(e.g On a client event like OnFocus or OnBlur or OnChange).

Check out like this:

use __doPostBack to refresh the UpdatePanel

If you have further questions,let me know.

Best Regards,


Hi,

Thank you for this great anwser. It's really what I was searching.

I have another question. I need a way to pass parameter from the client to know what to do when the page refresh on the server. For example, when the TextChanged occured on the TextBox1, I want to update some parts of the menu. Is it a good approach to pass parameter on the EventArguments of the __doPostback ? And which format do you recommand I use ? Or can you recommand me another way of doing that ?

function TextChanged(){ __doPostBack('ClientAjaxComm','');}
Thanks!

Hi,

It is a good approach to pass parameter on the EventArguments of the __doPostback.

Or you can store something into something hiddenfield,and get them at the server side.

It is up to you to which approach you use.

Thanks!

pagerequest manager events seems to be raised to many times by the browser

Hello,

I have the next issue in my web application.

On server i'm sending to the client during a server event with registerdataitem a string -an url.

On client in pageloading i'm getting the url and showing into a popup window. This is the code:

var

wind=null;

var

currenturl=null;

var

i=0;

Sys.Application.add_load(ApplicationLoadHandler);

function

ApplicationLoadHandler(sender, args)

{

//Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);

Sys.WebForms.PageRequestManager.getInstance().add_pageLoading(pageLoadingHandler)

}

//function EndRequestHandler(sender, args)

function

pageLoadingHandler(sender, args)

{

var dataItems = args.get_dataItems();

wind=document.getElementById(

'popupid');if (wind!=null)return;if (document.title.indexOf("Print")>=0)

currenturl=dataItems[

'ctl00_currenturl'];else

currenturl=dataItems[

'currenturl']if (currenturl !=null )//show the popup

{

wind=window.open(currenturl,

'popupid');

//DeleteFile(dataItems['currenturl']);works fine only on ie this solution

}

}

The problem is that the ajax pagerequestmanager event is raised too many times making the popup to be created to many time and sometimes browser to run out of resources.

How could i fix it i mean the pagerequestmanager event to be raised normaly i mean once.

I 'm using ie 6.5

Thanks

Hi,

Please use try this code snippet:

Sys.Application.add_load(ApplicationLoadHandler)

function ApplicationLoadHandler(sender, args)
{
var prm = Sys.WebForms.PageRequestManager.getInstance();
if (!prm.get_isInAsyncPostBack())
{
prm.add_pageLoading(pageLoadingHandler);
}
}

Hope this helps.

PageRequestManagerParserErrorException, is it due to web farm?

I implemented an ASP.NET 2.0 web application with the ASP.NET AJAX framework and the AJAX Control Toolkit. When I run it in my development pc, it works perfectly. But when it runs on a production server environment, which is a web farm, the following javascript error message prompts frequently on the browser:
Sys.WebForms.PageRequestManagerParserErrorException: This 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 '<!DOCTYPE html P'.
Anybody helps? It's my first project in my current company...

This problem is solved by adding a machinekey to the web.config.

PageRequestManagerParserErrorException with the New ASP.Net Ajax framework

I have two simple web pages with two update panels in them. The first one calls the second one using Server.Tranfer or Server.Execute and it gives the following error message:

Sys.WebForms.PageRequestmanagerParsererrorException: The Message received from the Server could not be Parsed. Common caused for this error are when the response is modified by calls to response.Write(), response filters, HttpModules, or server trace is enabled.

Now, this never happened with the previous framework, atlas. I've tried all possible solutions I could think of, but none worked so far.

Try to take a look at the following forums for?reference.
http://forums.asp.net/thread/1467462.aspx
Wish this can help you.

PageRequestManagerParserErrorException in my AJAX Web Page

Hi All,

I have started to get this intermittent error when I try to open my web site. The starting page uses the Accordion AJAXToolKit Control and a couple of update panels. I noticed that the PageRequestManagerParserErrorException error does not occur every time. Has anyone encountered this error and figured out the solution to this problem?

Thanks in advance

RK

See this article:

http://weblogs.asp.net/leftslipper/archive/2007/02/26/sys-webforms-pagerequestmanagerparsererrorexception-what-it-is-and-how-to-avoid-it.aspx


Great thanks. That helped me out. For others benefit I will just post a short blurb of the problem and the resolution. To start with the URL above is very informative.

The problem was that I am using a login control where the user enters the username and password and logs into my website. In my Login Control I had set the DestinationPageUrl to the page I wanted to display after the user was successfully logged in. The problem was occuring when that page was being displayed as it has a few update panels and I guess the client browser was receiving html that it did not know how to render. Thus the ParseRequestManagerParserErrorException.

Resolution: I changed my code to handle the "LoggedIn" event of the Login Control. I do an explicit Response.Redirect to display the page I want to display. This fixed the problem.

I am wondering if the Login Contol does a Server.Transfer instead of response.redirect. I know that the URL above mentions that a Server.Transfer can cause the problem to occur. Anywho I am happy :)

Reddy

PageRequestManagerServerErrorException

I have a web application built using ASP.NET Ajax 1.0. And now, I have a problem because when the IIS Server is restarted or not available the ajax engine display a message box with PageRequestManagerServerErrorException (Error 500). I would like to know if is possible treat this message and display a friendly message to user. How can I do this?I'm having the same error message pop up randomly after a page has been open for a while. I'm beginning to wonder if it is caused by Session going out of scope. With ASP.NET AJAX 1.0, do AJAX requests within an UpdatePanel moved the Session sliding expiration at all?

Hi,

This exception is thrown at the server. While in an async postback the normal exception/debug chain of the ASP.NET pipeline is ignored by default. You can either enable the normal custom error stuff in web.config by setting ScriptManager.AllowCustomErrorsRedirect on the current script manager to true, or you can handle the exception yourself at the server side by hooking to the AsyncPostBackError event on the script manager, or (if you just want to replace the message sent to the client and no more) you can set the AsyncPostBackErrorMessage.

Since async postbacks will still run through the session module at AcquireRequestState time, it seems unlikely that your sliding expiration interval is not updated. However, if you don't post back for a long period, your session will of course be abandoned. But this will not cause an exception, but rather just start a new session ...

-- Henkk


I found the problem, sorry I forgot to post it.

This error always occurred after a complete postback. I switched the postback out for an async postback, and the errors went away. Basically what was happening was that the user would sometimes be able to click on a control that would trigger an async postback before the entire page was rendered by the browser. This would break the AJAX scripts and throw that error message.

Thank you for the help with the custom errors, though!


I found what the error was. Apparently it always occurred after a regular postback so I was able to track it down. Users were sometimes able to click on a control that fired off an async postback before the entire page was able to load. This would break the AJAX scripts and throw the error.

Thanks for the help with the custom error messages!


Hello!!I have a page that has a textbox, a dropdownlist, a second textbox inside an update panel, and a second updatepanel with final textbox in it. I also have a calculate button

I am entering a number in first textbox and change selection in dropdownlist. It does an async postback with selectedIndexchanges and populates the second text box. Now when I press a calculate button the textbox in second update panel is supposed to return with values.

Both update panels are updatemode = conditional. First one is fired on selectedindexchanged of the dropdownlist and second on click of calculate button.

Everything works the first time. As soon as I calculate once, any subsequent calls to calculate or changing of the dropdown list gives the above error with server code = 500

How should I go about it?


In the calculate method, is there a control being updated that is NOT within the triggered UpdatePanel? That could be causing the issue.

PageRequestManagerServerErrorException, status code 504

I got the following error message on my ASP.NET AJAX web app:

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

What does it mean?Huh?

Hi monkeyno,

10.5.5 504 Gateway Timeout

The server, while acting as a gateway or proxy, did not receive a timely response from the upstream server specified by the URI (e.g. HTTP, FTP, LDAP) or some other auxiliary server (e.g. DNS) it needed to access in attempting to complete the request.

 Note: Note to implementors: some deployed proxies are known to return 400 or 500 when DNS lookups time out.

To troubleshoot this issue, we really need the source code to reproduce the problem, so that we can investigate the issue in house. It is not necessary that you send out the complete source of your project. We just need a simplest sample to reproduce the problem. You can remove any confidential information or business logic from it.

You get the Sys.WebForms.PageRequestManagerServerErrorException whenever the aspx handler throws an exception responding to an ajax.net update panel submit. If you took away the update panels you would see the classic asp.net exception page with lots of potentially useful information like the stack trace, but since the form submit has been ajaxified you just get a generic error message through a javascript alert. For example create an aspx page with an update panel containing a button and a multiline text control with the text set to "".

monkeyno:

Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server.

Clicking on the button you'll get the generic error: The status code returned from the server was: 500 Now try it again after placing the controls outside of the update panel. When you click the button you will get an exception page with details about a potentially dangerous/script-attack form value. The exception evens details a possible (though non-recommended) workaround of adding the attribute, ValidateRequest="false", to the aspx page directive. Of course for a real page it's a pain to strip out the update panels, so here is a quicker way to see the exception details. Just add the attribute, EnablePartialRendering="false", to your ScriptManager like below. Just set it back when you're done troubleshooting the issue.

Saturday, March 24, 2012

PageRequestManagerServerErrorException with error code 500

I am working on an ASP.NET AJAX web application. I got a PageRequestManagerServerErrorException with error code 500 every time when I try to populate a text box with a string contains some HTML tags (like <BR> for example). The full error message "Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500" appears in an alert box from javascript.
The main problem is that every next async post back generates the same error on the client side. Of course, I can check the passing string preliminarily, but my question is:
Is there a way to handle an error like this so the web application continues to run?
I have already check to clear error in Application Context on Application_Error event with Context.ClearError(), but it does not affect.

Hi!,

That exception is a callback exception and the PageRequestManager is the AJAX ScriptManager control.

You could customize the callback errors using the AsyncPostBackErrorMessage property of the ScriptManager.

Also, if you want to handle the error on server-side, use the ScriptManager_AsyncPostBackError event.

Please refer to this:http://support.microsoft.com/kb/193625

Check this articlehttp://blog.g9th.com/2007/01/14/unable-to-validate-data-at-systemwebconfigurationmachinekeysectiongetdecodeddata.aspx

Let me know if you need more info.
You can also see this thread for more help:http://forums.asp.net/t/1115331.aspx


Hi chetan.sarode!

Thank you for your post.

Yesterday I tried to handle this error on ScriptManager_AsyncPostBackError event, but unfortunately it doesn't fire.

The only one event I found to handle is Application_Error on Global.asax. I could ClearError in current HttpContext, but it doesn't affect on client side. The error still apears after every next async post back (the only difference is that alert box in javascript with the error message doesn't appear).

So, is there a way to prevent the response from the server to the client in that case. I mean it is better for me, the server sends nothing to the client instead of an error that stops every next async post back.

I appreciate any advice.

Thanks again.


I will look into that more...

Will let u knowSmile


Hi,

I got the same error a few days ago.

The following is my code that got the error:

<%@. Page Language="C#" %>

<%@. Import Namespace="System.Xml" %>
<%@. Import Namespace="System.Data" %>
<%@. Import Namespace="System.IO" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = DateTime.Now.ToString();

//string strxml = "<books><book>asp</book><book>asp1</book><book>asp2</book></books>";
string strxml = HiddenField1.Value;//.Replace("begin", "<").Replace("end", ">").Replace("slash", "/");
//DataSet myDS = new DataSet();
//XmlTextReader xtr = new XmlTextReader(new StringReader(strxml));
//myDS.ReadXml(xtr);
//DropDownList1.DataSource = myDS;
//DropDownList1.DataValueField = "book";
//DropDownList1.DataTextField = "book";

System.Xml.XmlDocument sa = new System.Xml.XmlDocument();
sa.LoadXml(strxml);
System.Xml.XmlNodeList saa = sa.GetElementsByTagName("book");
DropDownList1.DataSource = saa;
DropDownList1.DataValueField = "InnerText";
DropDownList1.DataTextField = "InnerText";

DropDownList1.DataBind();
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>

<script language="javascript" type="text/javascript">
// <!CDATA[

function Button2_onclick() {
document.getElementById("HiddenField1").value = test.XMLDocument.xml;
// var a = "";
// while(document.getElementById("HiddenField1").value != a){
// var a = document.getElementById("HiddenField1").value;
// document.getElementById("HiddenField1").value = document.getElementById("HiddenField1").value.replace("<","begin");
// document.getElementById("HiddenField1").value = document.getElementById("HiddenField1").value.replace("/","slash");
// document.getElementById("HiddenField1").value = document.getElementById("HiddenField1").value.replace(">","end");
// }
document.getElementById("Button1").click();
}

// ]]>
</script>

</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList><div style="visibility: hidden">
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
</div>
<input id="Button2" type="button" value="button" onclick="return Button2_onclick();" />
<asp:HiddenField ID="HiddenField1" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
<xml id="test">
<books>
<book>asp</book>
<book>asp1</book>
<book>asp2</book>
</books>
</xml>
</form>
</body>
</html>

I resolved it by changing the code into the following code:

<%@. Page Language="C#" %>

<%@. Import Namespace="System.Xml" %>
<%@. Import Namespace="System.Data" %>
<%@. Import Namespace="System.IO" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = DateTime.Now.ToString();

//string strxml = "<books><book>asp</book><book>asp1</book><book>asp2</book></books>";
string strxml = HiddenField1.Value.Replace("begin", "<").Replace("end", ">").Replace("slash", "/");

//DataSet myDS = new DataSet();
//XmlTextReader xtr = new XmlTextReader(new StringReader(strxml));
//myDS.ReadXml(xtr);
//DropDownList1.DataSource = myDS;
//DropDownList1.DataValueField = "book";
//DropDownList1.DataTextField = "book";

System.Xml.XmlDocument sa = new System.Xml.XmlDocument();
sa.LoadXml(strxml);
System.Xml.XmlNodeList saa = sa.GetElementsByTagName("book");
DropDownList1.DataSource = saa;
DropDownList1.DataValueField = "InnerText";
DropDownList1.DataTextField = "InnerText";

DropDownList1.DataBind();
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>

<script language="javascript" type="text/javascript">
// <!CDATA[

function Button2_onclick() {
document.getElementById("HiddenField1").value = test.XMLDocument.xml;
var a = "";
while(document.getElementById("HiddenField1").value != a){
var a = document.getElementById("HiddenField1").value;
document.getElementById("HiddenField1").value = document.getElementById("HiddenField1").value.replace("<","begin");
document.getElementById("HiddenField1").value = document.getElementById("HiddenField1").value.replace("/","slash");
document.getElementById("HiddenField1").value = document.getElementById("HiddenField1").value.replace(">","end");
}
document.getElementById("Button1").click();
}

// ]]>
</script>

</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList><div style="visibility: hidden">
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
</div>
<input id="Button2" type="button" value="button" onclick="return Button2_onclick();" />
<asp:HiddenField ID="HiddenField1" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
<xml id="test">
<books>
<book>asp</book>
<book>asp1</book>
<book>asp2</book>
</books>
</xml>
</form>
</body>
</html>

For more information,seehttp://forums.asp.net/t/1126640.aspx(embedded xml datasource)

Thanks

Paging using AJAX ASP.NET & DATAGRID

Hi all,

I am facing a problem ofPAGING in ajax with asp.net. I am not able to create paging on my web page. I have used update panel to view the data in datagrid.

I tried paging but its not working. Please suggest a solution to the above problem

Regards, Prem

Hi Prem,

I have a gridview and the Paging (WITHOUT causing postbacks) works just fine!

Did you check if all the callback options on the grid are disabled (enableSortingAndPagingCallbacks = false !!) ?
Then you just need to place it in an updatepanel.

If it still doesn't work, could you make me a (WORKING) demo with your grid which replicates the error/malfunction?

Kind regards,
Wim

Wednesday, March 21, 2012

Parser error

I have finished developing my company web site and published it and it works fine, But when they need changes..So I make the changes and published it again, then i have this error raisedOn my local machine when i run the debugger every thing seems to be okBut on internet it generates this error

Server Error in '/' Application.


Parser Error

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

Parser Error Message:Could not load file or assembly 'AjaxControlToolkit' or one of its dependencies. The module was expected to contain an assembly manifest.

Source Error:

Line 1: <%@dotnet.itags.org. Page Language="VB" MasterPageFile="~/ServicesMaster.master" Title=" Global Maintenance Agreements " %>
Line 2: 
Line 3: <%@dotnet.itags.org. Register
Line 4:  Assembly="AjaxControlToolkit"
Line 5:  Namespace="AjaxControlToolkit"


Source File:/Global Maintenance Agreements.aspx Line:3

Assembly Load Trace: The following information can be helpful to determine why the assembly 'AjaxControlToolkit' could not be loaded.

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].


Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42 does anybody has a solution?

try to install the ASP AJAX Extension on the IIS

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


I already did so from the begginning of the development and it works fine on the local server on my machine


try to reset the iis after installation iisreset from run command line


Please make sure the assembly AjaxControlToolkit.dll is contained in the bin folder of your application.

Partial Page Render not working with Master page

I have a child page using partial page rendering and the web controls are created programmatically. Ajax seems to have a problem with control ID naming when you create your web controls dynamically. When I run this it gives me an object instance error indicating the named control "Lable1" doesn't exist.

Has anyone else run into this problem?

Is there a work around?

Master Page

<%@dotnet.itags.org.MasterLanguage="C#"AutoEventWireup="true"CodeFile="MasterPage.master.cs"Inherits="MasterPage" %>

<!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>

</head>

<body>

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

<div>

<asp:contentplaceholderid="ContentPlaceHolder1"runat="server">

</asp:contentplaceholder>

</div>

</form>

</body>

</html>

CS child page

<%@dotnet.itags.org.PageLanguage="C#"MasterPageFile="~/MasterPage.master"Title="Untitled Page" %>

<asp:ContentID="Content1"ContentPlaceHolderID="ContentPlaceHolder1"Runat="Server">

<scriptrunat="server">

protectedvoid Page_Load(object sender,EventArgs e)

{

UpdatePanel up1 =newUpdatePanel();

up1.ID ="UpdatePanel1";

up1.UpdateMode =UpdatePanelUpdateMode.Conditional;

Button button1 =newButton();

button1.ID ="Button1";

button1.Text ="Submit";

button1.Click +=newEventHandler(Button_Click);

Label label1 =newLabel();

label1.ID ="Label1";label1.Text ="A full page postback occurred.";

up1.ContentTemplateContainer.Controls.Add(button1);

up1.ContentTemplateContainer.Controls.Add(label1);

Page.Form.Controls.Add(up1);

}

protectedvoid Button_Click(object sender,EventArgs e)

{

((Label)Page.FindControl("Label1")).Text ="Panel refreshed at " +DateTime.Now.ToString();

}

</script>

<div>

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

</asp:ScriptManager>

</div>

</asp:Content>

Create your controls in the Page_Init vs the Page_Load method.

-Damien


Damien -

I tried creating the controls in the Page_Init and it still will not work. The referrence to the control is still null. Is the page lifecycle timing wrong with the Button_Click event?


Try refering your control with:

YourUpdatePanel.ContentTemplateContainer.FindControl("YourControlName")


I don't have access to the UpdatePanel at design time.


UpdatePanel.ContentTemplateContainer.FindControl("controlName")


Thank you. Seems to work referencing the UpdatePanel "up1". Although you must instantiate "up1" as global. Simple but necessary.

Partial page refresh on master pages

Hi

I need some help. I'm working on a web site and i'm having problems to avoid a full page refresh when i navigate across the site using a menu control.

I use a master page to define the main aspect of my site. On the master page i placed a menu control and i want to refresh only the content place holder with the content page each time the user click on a menu item. I' ve tried to do this with ajax but until now, no luck.

If someone have a clue on how to do this i would very much appreciate it..Big Smile

Master pages are not frames...each time you click a link, you are on a new page, and the masterpage just gives it the same look. The only way that I have heard of to do that is with iFrames or having one page and load all your pages as user controls, although both methods are rather hacky.


I've alse tried to use iframes inside the master page and set the target property on the menu control to the iframe, but instead of loading the content page inside the iframe it opens a new window.

I placed the iframe within the content place holder on the master page. Maybe its not the right place to put it.


I think that you may need to do it on an aspx page, and all the pages you go to from there would need to not have a master page. Actually if you are doing it that way, you may not even need a master page. You could probably have a page that looks like the master page, but has an iFrame where the content template would be. I am not completely sure if that would work correctly though because we don't worry about that much though because most our pages act as separate applications, so there is not a lot of switching pages. Postbacks can also serve as a way for the user to see that they are going somewhere else, which works the way our site is, but may or may not for you.