Showing posts with label aspx. Show all posts
Showing posts with label aspx. Show all posts

Wednesday, March 28, 2012

Accessing the ScriptManager in code behind

In a User Control, how do you access the ScriptManager in code behind? The ScriptManager gets placed on the "parent" aspx page, but seems not to be accessible from any user controls ascx that get added to that page.

Specifically, I would like to capture the ScriptManager.PreRender event for use in a Repeater control.

Is there a way to raise an event in the parent ASPX page that the child user control can pick up?

if you want to call parent control,

you can use

this.Parent.FindControl..

i am not sure why you want user control to do something with "ScriptManager.PreRender event"

why cant you use ScriptManager.PreRender event to do something for your user control ?

you can always use

Page.FindControl to call your use control in the ScriptManager.PreRender event


Hey, thanks for your reply. I could really use some help.

The goal is to use an update panel inside a repeater, both of which are use controls loaded onto a page. There are some inherint challenges with this. The first being that 1) the ScriptManager is not accessible because it is in the parent, 2) the update panel elements don't seem available at the time of the event. Below is my code to access them, but the me.parent.findcontrol always returns "nothing."

My research has shown me that the ScriptManager.PreRender is the event that I can access/ change these values.

My entire page works great, except the update panel inside the repeater does not update and I cannot access the objects within it (i,e, a label)

Sub handleTypeTest(ByVal senderAs System.Object,ByVal eAs System.EventArgs)

Try

Dim tempVAsString = ddlAnswerType.SelectedValue

ddlAnswerType.Visible =False

Dim tempUPAs UpdatePanel =Me.Parent.FindControl("upDropDowns")

IfNot tempUPIsNothingThen tempUP.Update()

Dim tempLabelAs Label =CType(Me.Parent.FindControl("lblTest"), Label)

tempLabel.Text ="changed"

Catch exAs Exception

EndTry

EndSub

Accessing Controls outside Update Panel.

Hello,

I am having a webapplication in which i am having two pages. w1.aspx and popup.aspx,

On w1.aspx I am having a Menu control and a UpdatePanel control (Ajax Control) and then under Update panel i am having a link named SigIN and a button named refresh,On the click of SignIN l;ink the popup.aspx opens which provides functionality to signin , On that popup window i am logging user in using ajax so there is no refresh in that popup when user signing in.

Now after user signin succefully from the popup.aspx page that is a popup window i am displaying a messge to the user there that "You are SignIN succesfully and now close this window"

When user close the popup window then user comes on the w1.aspx , Now i want when user press the Button Refresh that is present on the w1.aspx under updatepanel control.. then the text of first menu item in the menu control that is present on the page w1.aspx but not under updatepanel will be changed from SignIN to SignOUT, and the link label that is present on this page under updatepanel will be hidden after the click of this refresh button,

But the problem is on the click of this refresh button the link will be hidden but the text of the menu item is not changing. That is i am not able to acces the controls that are present outside the updatepanel control.

WHY??

is it possible to acces the control properties present outside the UpdatePanel control on the click of a button that is present under UpdatePanel control.

????????

Hi, you must to place any control that an another control on UpdatePanel changes on another UpdatePanel. Controls on UpdatePanel can′t to change controls outside UpdatePanel (Don′t happens an error, just don′t works). Don′t need to be the same UpdatePanel. Can be another one, but must be inside of UpdatePanel.


Hi mgodoy_desenv,

Can u please provide me a sample code for the same.

Thanks in Advance...


My codes are very big, so I will to try show. I don′t speak English so much, so excusive for my way of writing:

In code below, you have a control inside UpdatePanel and another one outside:

<html>
...
<asp: Textbox ID="Textbox1" runat="server"/>
...
<asp: UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="Button1" runat="server"/>
</ContentTemplate>
</asp: UpdatePanel>
</html
To Button1 to change the Text property of Textbox1, Textbox1 must to be placed inside of an UpdatePanel. You not will have an error if that don′t to happen. Just don′t works.

To work, the Textbox1 must be a place inside of an UpdatePanel. The good news is that it don′t need be inside of same UpdatePanel. It can be placed inside another one.

The code below corrects the problem:

<html>
...
<asp: UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>

<asp: Textbox ID="Textbox1" runat="server"/>
</ContentTemplate>
</asp: UpdatePanel>

...
<asp: UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="Button1" runat="server"/>
</ContentTemplate>
</asp: UpdatePanel>
</html>


Hi,

Your idea is working for a single page but when i am working with master page and menu then i think its not working properly.

Wht i am doing is,

I am having a webpage w1.aspx which is using the master page m1.master, Now my master page having a menu. I want to update the value of that page from the w1.aspx on the click of a button that is present under an updatepanel on w1.aspx.

Now as you said take the control inside the update panel whose value you wann update, so i have taken the menu control under the update panel and then by taking the refrence of menu control on the page w1.aspx i am updating the value of the menu items. But after updatiing the values when i am moving the mouse over the menu items then it gives me the error. some javascript error. I d't know why this ?

If u can then try to do the same thing as i said... with master page..and menu contriol

....


There are many problems with use of UpdatePanel. We must be carefully with it, cause asynchronous post back uses many JavaScript. I haved, for example, many problems with Server.Transfer and UpdatePanel.

Your case isn′t diferent. UpdatePanel can has updated the menu control in a wrong way. Try do this:

1. Use a DataSource to menu. Create a method to populate it with a DataTable, or Xml.
2. When you to want to change items of menu control, change the DataSource (DataTable, or Xml) and call DataBind method of menu.

I don′t speak English so much. So, excuse me for my way of writing.


The Menu control is one of the few ASP.NET controls that isnot compatible with async postbacks. Seehttp://asp.net/AJAX/Documentation/Live/overview/UpdatePanelOverview.aspx#UpdatePanelCompatibleControls for reference.

I would think you should leave the Menu controloutside of the UpdatePanel, but make it a trigger for the UpdatePanel you want to update with <asp:UpdatePanel ...><Triggers><asp:AsyncPostBackTrigger ControlID="MyMenu" /></Triggers>...</asp:UpdatePanel>.


Actually, rereading the question, I may have missed the point here... I was assuming the Menu control was the one triggering the update, but that some other control on the page was being updated.

If the Menu control is the one you want to update, I think you're out of luck, since the Menu can't live inside an UpdatePanel.

Monday, March 26, 2012

accessing arg.IsValid from callback function.

I have a custom validator on an aspx page which calls the function below: the args object passes in the value from a dropdownlistbox and has a property IsValid. The problem I'm facing is I don't have access to the results ofOnDoesExchangeRageExistComplete in the main fuction, because I want to set args.IsValid to the result. Any ideas on how I can do this?

This is the manin function called from the aspx page

functionDoesExchangeRateExist(sender, args)
{
//pass in the period date in args.value to the webservice.
UtilityService.DoesExchangeRateExist(args.Value, OnDoesExchangeRageExistComplete); //What I would like to do is set args.IsValid to the result of the webservice call. Because this determines if the page is submitted.
}

//----------------------------------

function

OnDoesExchangeRageExistComplete(result)
{
var errMsg = document.getElementById( "lblErrorMsg");
if(result ==true)
{
errMsg.innerHTML =""
returntrue;
}
else
{

errMsg.innerHTML =

"Exchange rates are not available for selected period date. Please select a different period date."\n

returnfalse;\n

}

\n

}

\n

\n

thanks,

\n

Garfield.

\n\n",0]);D(["ce"]);//-->returnfalse;

}

}

thanks,

Garfield.

I think you can returnargs.IsValidas a return value of the WebMethod?UtilityService.DoesExchangeRateExist?and access it in the callback of the client side through javascript.
Try to take a look at the following for details about calling web service in javascript from the client side.
If the web service class on the server includes a web method that does not return data, you can call the web service without having to handle a response. This is the simplest web method call that can be made from the client. For example, your application has the following web method:
?
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[Microsoft.Web.Script.Services.ScriptService]
public class Parts : System.Web.Services.WebService
{
[WebMethod]
public void NoReturn()
{
//do work here
System.Threading.Thread.Sleep(2000);
}
}
?
The following JavaScript can be used to invoke that web method
?
function RunWebService()
{
Parts.NoReturn();
}
?
If the webservice is in a custom namespace, you would need to fully
qualify the call to the webservice. For example, if the WebService
has a namespace of MyCustomNameSpace.WebServices, the above JavaScript
becomes:
?
function RunWebService()
{
MyCustomNameSpace.WebServices.Parts.NoReturn();
}
?
Getting a return value?
In a scenario where the web method has a return value, then the asynchronous invocation model requires providing a callback function that will be called when the web service call returns. The callback function has an input parameter that contains the results of the web service call.
?
The server-side AJAX stack will appropriately serialize the return value from the web method, and the client-side AJAX stack will deserialize the data to an appropriate JavaScript type to be passed to the callback function.
?
On the Server-side, there is a WebMethod that returns a string:
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[Microsoft.Web.Script.Services.ScriptService]
public class Parts : System.Web.Services.WebService
{
[WebMethod]
public string DynamicDropdown()
{
string tmpDropDown;
tmpDropDown = "<select id=test name=test><option value=Part1>Part1</option><option value=Part2>Part2</option></select>";
return tmpDropDown;
}
}
?
When you call the web service in client script, the call will need to have a callback function specified to handle the return value. The following script demonstrates calling the DynamicDropdown WebMethod of the Parts Web Service and specifies OnComplete as the callback function. The OnComplete function has an input paramter which is the return object from the web service call, in this case, this will be the string value. The OnComplete function then takes the return value and inserts it as the innerHTML property of a span with ID DynamicArea. The result is that a dropdown appears on the page.
function InsertDropdown()
{
Parts.DynamicDropdown(OnComplete);
return false;
}
function OnComplete(result)
{
DynamicArea.innerHTML += result;
}
Passing primitive type parameters to web method
If the web method takes input parameters, then the JavaScript invocation of the method will take corresponding JavaScript parameters. The parameter values will be serialized by the AJAX stack into JSON and packaged in the body of the request and then de-serialized as .Net types corresponding to the signature of the web method.
?
For example, given the following server method that accepts a string parameter and returns a string:
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[Microsoft.Web.Script.Services.ScriptService]
public class Parts : System.Web.Services.WebService
{
[WebMethod]
public string EchoString(String s)
{
return s;
}
}
?
You would use the following JavaScript to call the web service, pass the string parameter and include the callback function:
?
function CallEchoString()
{
Parts.EchoString(form1.GetString.value, OnCallBack);
}
function OnCallBack(results)
{
alert(results);
}
?
The call to the EchoString web method on the Parts.asmx web service is taking the value from a textbox named GetString in a form with ID of "form1" to pass as the input parameter and specifying OnCallBack as the callback function. The OnCallBack function has an input parameter of "results" which is the return type from the EchoString web method. The JavaScript then displays that in a popup box.
Specifying a callback for failure cases?
If the request to the web method is unsuccessful, whether because of error, timeout, or if server code aborts the request, then the callback specified for successful completion will not be called. A second callback function can be specified in the call to the web service for failure cases, receiving an error object as parameter, as in the following javascript:
?
function CallService()
{
PeopleServices.ThrowError(OnCallBackThrowError, OnError);
}
function OnCallBackThrowError(result)
{
alert("OnCallbackThrowError: " + result);
}
function OnError(result)
{
alert("OnError: " + result.get_message());
alert(result.get_stackTrace());
}
?
In the code sample, the ThrowError method of the PeopleServices web service does not take any input parameters. The method call passes the callback function "OnCallBackThrowError" and a method for handling any error condition called "OnError". The OnError method takes an input parameter which is a error object that contains the error message and stack information passed from the server if a .NET Exception was thrown. In this case, the information is displayed in popup windows, but once you have the errors in the browser, you can notify the user in any manner you feel is appropriate.
Using the same callback from multiple callers?
You can leverage the same callback function on the client for multiple web service calls. This allows you to avoid having to write a client function for each callback. In order to differentiate the calls, you pass a user context object that contains information that can be used to tell the requests apart. The user context object can be any JavaScript primitive type, array, or object.
?
For example, let's say you have a web service that contains a web method that you need to call multiple times from the client. You need to know which response corresponds to each call. For example, the first call's return value is placed in Span1 and the second call is in Span2. In order to do this, you can associate context information with the request and you can use the context information to distinguish which request is providing the response. This information is not passed to the server by default. If you want to pass this information to the web service, you would need to pass it as an input parameter to the remote method.
?
On the server, you have the following web service method that is taking in the a string which should be a stock symbol and returning a string:
?
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[Microsoft.Web.Script.Services.ScriptService]
public class Parts : System.Web.Services.WebService
{
[WebMethod]
public string UserContextSample(string stockSymbol)
{
string returnValue = String.Empty;
//do work here to look up stock symbol info
return returnValue;
}
}
?
On the client, you create a JavaScript object to store context specific information and pass that as the last parameter to the web service call. In the sample below, we're creating a dictionary object on the client with a key of contextKey and a value of a stock quote. The syntax for the web service call is:
?
WebService.Method(InputParams, CallBackMethod, ErrorMethod, contextInfo);
?
function CallServicesTest()
{
var userContext1 = {contextKey:"MSFT"};
Parts.UserContextSample("MSFT", OnCallBack, OnError, userContext1);
var userContext2 = {contextKey:"AAPL"};
Parts.UserContextSample("AAPL", OnCallBack, OnError, userContext2);
}
In the callback function, you add a second input parameter that contains the context passed in the web service call. This way you get the results of the web service call in the first input parameter and the context information in the second parameter. In this case, we're checking the context information and inserting text into specific spans on the page along with the response from the web service.
?
function OnCallBack(results, userContext)
{
switch(userContext.contextKey)
{
case "MSFT":
SPAN1.innerHTML = "Microsoft " + results;
break;
case "AAPL":
SPAN2.innerHTML = "Apple " + results;
break;
}
}
Using the same callback for different web methods?
This scenario is similar to using the same callback for multiple calls with the exception that you have two separate web service methods on the client that are using the same callback method. In this scenario, you include a third input parameter on the callback function to receive the web service call that the response is associated to.
?
For example, you have two Web Methods that your function needs to call, but you want to have a single callback method. You can tell which web method is returning by accessing the optional third input parameter to the callback function.
?
On the server you have:
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[Microsoft.Web.Script.Services.ScriptService]
public class Parts : System.Web.Services.WebService
{
[WebMethod]
public string EchoString(String s)
{
return s;
}
[WebMethod]
public string AnotherEchoString(String s)
{
return s;
}
}
?
On the client you have a button that has an onclick method calling GetEcho() function in JavaScript:
?
function GetEcho()
{
Parts.EchoString("This is echo number 1", OnCallBack);
Parts.AnotherEchoString("Another echo string!", OnCallBack);
}
function OnCallBack(results, userContext, sender)
{
alert(results + "\n" + sender);
}
?
When OnCallBack runs, you will get an alert dialog with the string you passed to the web service along with Parts.EchoString or Parts.AnotherEchoString.
Passing and receiving a server type?
As mentioned previously, the AJAX networking stack will generate proxy scripts for any server type that is referenced as an input or output parameter by the web methods contained in linked web services. This allows a developer to access these types on the client in a similar fashion as they would on the server. The types are serialized using JSON serialization which is covered in the next lesson.
?
For example, let's say you have the following web service called PeopleServices. This web service has a method called NewPerson that takes in 3 parameters; 2 Person objects and 1 object of type bool. The return value is also of type Person.
?
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[Microsoft.Web.Script.Services.ScriptService]
public class PeopleServices : System.Web.Services.WebService
{
?
[WebMethod]
public Person NewPerson(Person parent1, Person parent2, bool female)
{
Person _newPerson = new Person();
//Do other work
return _newPerson;
}
}
When you add this web service to the ScriptManager, the client will make a request for the proxy script as discussed in the Proxy Generation section. The result is that the Proxy script will have the web service method as well as the properties for the Person class. The person class is defined as the following on the server:
?
public class Person
{
public string Name
{
get { return _name; }
set { _name = value; }
}
public int Age
{
get { return _age; }
set { _age = value; }
}
public int Height
{
get { return _height; }
set { _height = value; }
}
}
?
On the client, you would need to generate two objects of type Person and pass them as parameters to the web service. In the callback script, the result parameter will be of type Person. Here's a sample JavaScript function that takes the values of textboxes on the page and creates two Person objects, then calls the NewPerson object on the above web service.
?
function GetNewPerson()
{
var person1 = new Person();
var _name = document.getElementById('p1FirstName');
var _age = document.getElementById('p1Age');
var _height = document.getElementById('p1Height');
person1.Name = _name.value;
person1.Age = _age.value;
person1.Height = _height.value;
?
var person2 = new Person();
_name = document.getElementById('p2FirstName');
_age = document.getElementById('p2Age');
_height = document.getElementById('p2Height');
?
person2.Name = _name.value;
person2.Age = _age.value;
person2.Height = _height.value;
PeopleServices.NewPerson(person1, person2, true, OnCallbackGetNewPerson, OnError);
}
?
Here is a sample callback function that handles the return type from the NewPerson method. The result parameter is a Person object and you can directly access the properties. In this case NewPerson is the ID on a Div in the page.
?
function OnCallbackGetNewPerson(result)
{
var newPerson = result;
NewPerson.innerHTML = "New Person <br/>";
NewPerson.innerHTML += "Name: " + newPerson.Name + "<br />";
NewPerson.innerHTML += "Age: " + newPerson.Age + "<br />";
NewPerson.innerHTML += "Height: " + newPerson.Height + "<br />";
}
When you run pages that make these calls and check out the network traffic, you'll see the following:
Web service call is a POST to …/PeopleService.asmx/js/NewPerson. Since the request ends in /js/NewPerson, the AJAX HttpHandler will handle the request to the web service. The Content-Type of the request is application/json.
Request Body contains all the data to create the Person object on the server. The main piece is the __type parameter which tells the server what type to create:
?
{"parent1":{"__type":"Person","Name":"Name1","Age":"12","Height":"60"},"parent2":{"__type":"Person","Name":"Name2","Age":"24","Height":"72"},"female":true}
The response also has a Content-Type of application/json and has a similar body containing the __type parameter and values necessary to create the Person object on the client:
?
{"__type":"Person","Name":"Name1name2ella","Age":23,"Height":71}
?Demo is FireForgetDemo.aspx
?Wish the above can help you.

Access Properties in codebehind

How can i access properties of DragPanel in codebehind?

For example, in test.aspx i have DragPanel, i want change the DragHandleID property in codeBehind... ? I cant access it. Thanks for any reply.

ThoNT

Assuming it's the first one in the list...

dragPanelExtender1.TargetProperties[0].DragHandleID = "newHandleID";


sburke_msft:

Assuming it's the first one in the list...

dragPanelExtender1.TargetProperties[0].DragHandleID = "newHandleID";

but if's not the first one in the list... and we dont know the index of it. (because we creat it by an for looping)


Well you can also look at the TargetID property to see which control it's extending

Hi ThoNT,

I think the easiest way to dynamically get the properties is to use the control you attached the extender to (i.e. the control you're setting as the "TargetControlID"). You can just do the following:

DragPanelProperties properties = dragPanelExtender1.GetTargetProperties(myControl1);if (properties !=null){ properties.DragHandleID ="newHandleID";}

Thanks,
Ted


Thank Ted Glaza.

i have just know functionGetTargetProperties from you!

Access is denied

Hi..

I have aspx page, and this page contain iframe. In the Iframe i try to open aspx page that contain ajax controls like animation, progress bar... the problem that i have is: when i try to move my cursor on the image that open the animation box, i get the following error: Access is denied.

When the progress bar is starting to work i get the same error..so, in each control that i am using i get this error..and i don't know how to solve this..

thank you...

The "Access Denied" error in any browser usually means that a script in one window or frame is trying to access another window or frame whose document's domain is different from the document containing the script. What can seem odd about this is that you get this error in IE for Windows frequently when a script in one window generates a new window (withwindow.open()), and content for that other window is dynamically created from the same script doing the opening. Thefocus() method also triggers the error.

The error can also occur if scripts try to access objects, properties, or methods that have been locked down by Microsoft's security platoon. For instance, thedocument.styleSheets.rules property used to be accessible in IE 5 and IE 5.5, but is not in IE 6.

For the new window problem, there is a bit of history associated with the problem and workarounds. For example, the problem occurs frequently when the scripts are being run from the local hard disk. You get a clue about the situation in the titlebar of the new window: It forces anabout:blank URL to the new window, which is a protocol:domain that differs from wherever your main window's script comes from. If, however, you put the same main window document on a server, and access it via http:, the problem goes away.

There is a workaround for the local-only problem: In the first parameter of thewindow.open() method call, load a real document (even if it is a content-free HTML document) into the sub-window before usingdocument.write() to generate content for the subwindow. The loading action 'legitimizes' the window as coming from the same domain as your main window's document.

(This solution does not affect scripts that load a page from a secure server into a separate window or frame. Anhttp: protocol in one window andhttps: in the other--even if from the same server.domain--yield a security mismatch and "Access Denied." Setting thedocument.domain properties of both pages may solve the problem (but I am unable to test it for sure).)

For other situations (such as thedocument.styleSheets.cssRules problem, there are no workarounds, so you'll have to find another way around your task.

One more source of this error in IE occurs if you assign a too-long search string to a URL or a form (using the GET method) has lots of elements and data. The HTTP GET method has a built-in limit of approximately 512 characters. If you run into the problem, change the method to POST, which has no data length limit. But POST won't reflect the search string in the URL of the replacement page (in case you're expecting to parse that data as a way to convey data from one page to the next).

Access denied Error

HI,

I am getting an Access denied error, if I use AJAX in ASPX page..

intially I got Javascript window ( Do you wish to debug..) When I said 'Yes' it showed me the code below..

//------------------
// Copyright (C) Microsoft Corporation. All rights reserved.
//------------------
// MicrosoftAjax.js
Function.__typeName="Function";Function.__class=true;Function.createCallback=..................
........................
g=e.screenLeft-top.screenLeft-top.document.documentElement.scrollLeft+2 ------ its showing error at this point..

What is the solution for this?

Thanks


Try to disable the javascript debugging. See what happens then

Configure AJAX properly

http://www.asp.net/AJAX/Documentation/Live/ConfiguringASPNETAJAX.aspx


Hiasppick,

Please refer to these entries:

http://blogs.msdn.com/delay/archive/2007/02/05/safely-avoiding-the-access-denied-dialog-how-to-work-around-the-access-denied-cross-domain-iframe-issue-in-the-ajax-control-toolkit.aspx

http://weblogs.asp.net/bleroy/archive/2007/01/31/how-to-work-around-the-quot-access-denied-quot-cross-domain-frame-issue-in-asp-net-ajax-1-0.aspx

Hope this helps.

Saturday, March 24, 2012

About SurveyQuestions.xml

Hi,

Where can I get theSurveyQuestions.xml used by "UpdatePanelHowTo6 Sample - SurveyQuestionsExample.aspx" ?

Thanks a lot.

Kevin

Hi

I also did not findSurveyQuestions.xmlon net but i have createdSurveyQuestions.xml

my selef

Best Reqard.

Fayaz Soomro

save followin as SurveyQuestions.xml

<?

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

<Questions>

<QuestionTitle="Favorite color?"ID="1">

<Choices>

<Choice>Red</Choice>

<Choice>Green</Choice>

<Choice>Blue</Choice>

</Choices>

</Question>

<QuestionTitle="Favorite day or the week?"ID="2">

<Choices>

<Choice>Monday</Choice>

<Choice>Tuesday</Choice>

<Choice>Wednesday</Choice>

<Choice>Thursday</Choice>

<Choice>Friday</Choice>

<Choice>Saturday</Choice>

<Choice>Sunday</Choice>

</Choices>

</Question>

<QuestionTitle="Favorite Activities?"ID="3">

<Choices>

<Choice>Gardning</Choice>

<Choice>Skiing</Choice>

<Choice>Walking</Choice>

<Choice>Reading</Choice>

</Choices>

</Question>

</Questions>

about ScriptManager

if there was a user control (ascx) which have a ScriptManager control in a page(aspx), would there need a ScriptManager in my page?

about master page?? if have a ScriptManager control , how can i deal with its son page?

thankyou

Hi,

you can only have one ScriptManager control. My suggestion is to put it in your page (or in the master page). If you need to add scripts or services references in user controls, you can use the ScriptManagerProxy control.

I think you're getting a sense for the awkwardness of the current implmentation.

If you'd like, you can help me recommend a more elegant solution by contributing here:

http://forums.asp.net/thread/1364014.aspx

about new atlass document

I found that the new atlas's document(http://atlas.asp.net/docs/Default.aspx) had used atlas's updatepanel.
Where to download the new atlas's document's source code?

You can download the latest Atlas CTP drop from this URL:http://atlas.asp.net/default.aspx?tabid=47&subtabid=471

Hope this helps,

Scott


thanks for your reply.
I had download it .But I can't find new atlas document's source code files.(I had old document's source code.)
How to get it?

I'm not sure what you mean by "old document's source code". Can you explain more? What document are you referring to?

Thanks,

Scott

A simple AJAX problem

I have had a ASP.NET page. Now I want to experiemt with the AJAX function. So first I drop aScriptManager and then aUpdatePanel onto the .aspx. After that, I further drag a label(Label1) and a button inside it and in a additon, I also drag a label(Label2) outside the UpdatePanel.

Inside the page_load event handler is:

Label1.Text = DateTime.Now.ToString();
Label2.Text = DateTime.Now.ToString();

However, when I click the button, two labels are updated as if a normal postback. In other words, the partial-update does not work.

What details do I miss so that the partial-update function do not work properly?

Thanks in advance.

Ricky.

Try this way..

<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>

//Place the Label within the Update panel Content template
<asp:Label ID="Label1" runat="server" Style="position: relative" Text="Label"></asp:Label>
</ContentTemplate>

//Add the trigger attribute and add as shown

<Triggers>
<asp:AsyncPostBackTrigger ControlID ="Button1" EventName ="Click" />
</Triggers>
</asp:UpdatePanel>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Style="left: 128px;
position: relative; top: 48px" Text="Button" /></div>
</form>

Thats all.

Any questions still, let me know

Sri


Hi, sridhar. After copying the web.config from an "ASP.NET AJAX-Enabled Web site" to my website. Everything got all right.

Anyway thanks for your reply.

Regards,

Ricky.

Wednesday, March 21, 2012

A problem when I use script manager, script manager proxy

I have an default.aspx and 3 link in that page. When I click to one of these links I want to load a usercontrol( ex: control1.ascx ) and in this user control I also use ajax in this control. Other Developer said that I must use a master page and declare a script manager in this page. In usercontrol I just need to use scriptmanagerproxy... But I don't know exactly what I have to do. Can you help me. Thanks all of you a lot.

Hi hamanhtuan,

Well the scriptmanagerproxy is an extended version of the scriptmanager. In your situation i think you can fix it with just a scriptmanager on your .aspx page and no scriptmanagerproxy on the user control. When your webpage contains a scriptmanager control and the usercontrol isn't you can still make use of the Ajax functionalities. keep in mind that when you deploy this usercontrol on an apsx page where you're not have a scriptmanager then it isn't working. The scriptmanagerproxy isn't a solution for this problem because the scriptmanagerproxy also needs a scriptmanager control. So drop a scriptmanager on your aspx page and other controls (Updatepanels) in your usercontrol and it will work. Hope it helps.

Regards


When I remove a scriptmanagerproxy on my controls and use Updatepanels in my usercontrol then my *.aspx can load these control. But in my control, I have a gridview, a refresh button and I want to auto update this gridview when click this button. How can I do this work ? Thank you for your last answer.

Hi hamanhtuan,

SO your gridview needs to be in the updatepanel and the button should be the trigger for the updatepanel. this will partial update the controls inside the update panel but take a look at the following:

Controls that Are Not Compatible with UpdatePanel Controls

The following ASP.NET controls are not compatible with partial-page updates, and are therefore not supported inside anUpdatePanel control:

TreeView andMenu controls.


Thank you for your answers.