Showing posts with label click. Show all posts
Showing posts with label click. Show all posts

Wednesday, March 28, 2012

Accessing PopupControl methods from client script

Hi,

How can I access the client-side functions of the PopupControl (namely "hide()")? Rather than the user having to click elsewhere on the page I also want to have a close button. According to the Firebug DOM explorer, the div element thats used for the popup has a property "PopupBehaviour" but trying to access this throws an error.

Cheers

Hi,

Not sure if this is the "correct" way to do this but I do this:

ButtonClose.Attributes.Add("OnClick","__AjaxControlToolkit_PopupControlBehavior_VisiblePopup.hidePopup();");

HTH

Jeff


I'm running into the same problem. I want to do a client-side close of the popupcontrol. I tried getting the uniqueid of the panel that's being popped up and setting the .style.display property to 'none' and that closes the panel but the problem is that whatever controls the panel used to cover are disabled. They've done this on purpose to disable controls from underneath the overlayed panel from being selected while you are selecting controls on the panel. So my solution half works.

Does anyone in the ASP team or someone who's had a need to close the popupcontrol control on the client-side have a clean a proper solution for this? Doing a postback to close the extender is a really stupid way of closing it so I'm sure someone must have come across this... Thanks!


Hi,

In version 1.0.10123.0 of the toolkit i do this on the client side which seems to work, as I said before I'm not sure if this is the correct way but it works.

AjaxControlToolkit.PopupControlBehavior.__VisiblePopup.hidePopup();
hth
Jeff 

I found this nice free popupcontrol. It comes with full source and also the .dll. Its nice to have this control in your Visual Studio Toolbox. ;)

Dainty Date


Jeff, thanks that works.


Cool. I will try that. Currently I use a button that calls "document.body.click()" to simulate the clicking elsewhere outside of the popup which effectively closes it.

Hi,

The easeist way to do this is add a BehaviorID="MyPopup" on the extender and then usevar behavior = $find('MyPopup'); in script.

Thanks,
Ted

Saturday, March 24, 2012

about Atlas

Hello:

I'm new in Atlas, and I need help to understand :)

My scenario is that I have one gridview (vsnet 2005) and a button. When I click button, I call remote web service (http:outerIP/myservice.asmx) that returns data used for gridview's datasource.

I have seen examples for calling from javascript to web service, but I don't understand proccess.

1- I add the web reference to my vs2005 (with atlas template) project.

2- I modify this code that template created in aspx.

<asp:ScriptManagerrunat="server"ID="scriptManagerId"><Scripts><asp:ScriptReferencePath="CallWebServiceMethods.js"/><-----</Scripts><Services><asp:ServiceReferencePath="http://OUTERIP/webservices/MyService.asmx"InlineScript="false"/></Services></asp:ScriptManager>

my ask are:

    this .js file "CallWebServiceMethods.js"... how is generated? is it a copy of real web service?Must I make this .js?Is not intelllisense in javascript for calling webservice methods?If i call webservice method from client side in javascript... how can I to send to grid this received datasource?

Thanks a lot and regards!

For your four questions, I'd like to share my ideas with you for reference.
1.The Services collection allows you to wire up web services that can be consumed via client side script. The ScriptManager will generate proxy JavaScript scripts that allow the developer to use similar syntax on the client as is used on the server. The supported bits will not support calls to Windows Communication Foundation (WCF) services, however, this functionality will be added to the non-supported CTP builds in the future.
The AJAX Extension includes an HttpHandler that is used to generate the proxy scripts and handle JSON serialization called Microsoft.Web.Script.Services.ScriptHandlerFactory. Internally the HttpHandler routes .asmx calls that require JSON serialization to the AJAX networking stack.Calls to .asmx that don't use the special syntax (http://.../foo.asmx/js/methodname) are routed to the original ASP.NET 2.0 .asmx handler. Note that this means if a developer created a custom .asmx handler, when AJAX web services are enabled on a site the ScriptHandlerFactory will instead always fall back to System.Web.Services.Protocols.WebServiceHandlerFactory. There is no capability to chain the AJAX handler to a custom .asmx handler.
You wire up the web services to the <ScriptManager> by adding a ServiceReference to the Script Manager. The following demonstrates how to add a service reference to foo.asmx. You can also do this by accessing the Services collection in the Property pane of the IDE.
<asp:ScriptManager runat="server" ID="scriptManager">
<Services>
<asp:ServiceReference Path="~/.../foo.asmx" />
</Services>
</asp:ScriptManager
This will result in javascript objects being instantiated in the browser which are proxy objects for corresponding .NET classes in foo.asmx. The proxy objects are used
a)To make asynchronous requests in JavaScript to the asmx web methods
b)To create and initialize instances of proxies of server data types. This allows developers to pass complex objects as parameters as well as handling complex objects in the response.

ServiceReference Properties
You add a ServiceReference control to the <Services> section for each web service you need to access via JavaScript. The reference drives the process of requesting the proxy script on the client. The proxy script is covered later in this lesson. The ServiceReference control has two properties: InlineScript and Path.
InlineScript - The InlineScript attribute on the ServiceReference tag determines whether the script for generating the Javascript proxies is included within the page, or is downloaded as a separate script resource. The default value is false.

<asp:ServiceReference Path="~/.../foo.asmx" InlineScript="true" /
When InlineScript is set to false (or is absent) then the proxy generation script is obtained by a separate request to http://.../foo.asmx/js which is handled by the AJAX HttpHandler. Since the script can be cached in the browser, this option is preferable when multiple asmx pages use the same service reference.

When InlineScript is set to true the proxy generation script is included as an inline script block within the page. This can improve performance by reducing the number of network requests, particularly if there are many service references within the page and other pages do not reference the same services.

Path: The Path property specifies the URL for accessing the web service. The ServiceReference tag can only be used for local services (i.e. services within the same domain). Local services can be addressed by a relative, app-relative, domain-relative or absolute path. For domain-relative or absolute paths it is up to the developer to ensure that the path does correspond to the same domain, and so will actually work. The proxy generation code will initialize the path property to the corresponding domain-relative path.

This means that if you enter have the following:
<asp:ServiceReference InlineScript="true" Path="http://mydomain.com/Parts.asmx" /
The proxy script will be requested using the full URL:
http://mydomain.com/Parts.asmx/js

However the path in the proxy script will call the webservice using the virtual path of /Parts.asmx.

If you specify InLineScript="true", you have to either use a virtual or relative path. You can also use the ~/ syntax to have ASP.NET build the app relative path for you. You will get the following error message if InLineScript="true" and the Path is pointing to a different domain than the ASPX page was requested from:

The path "http://test.com/TestServices/WebService.asmx" is not supported. When InlineScript=true, the path should be a relative path pointing to the same web application as the current page.

Path to external services
For external use of services, using a ServiceReference with an absolute URL will fail, as specified above. It is recommend that developers do the following:
?Download the script, using http://mydomain.com/Parts.asmx/js
?Open the .js file and set the correct value of the path property. If the web service class is called "WebService" and the site is http://test.com, you would do the following:

Change: WebService.set_path("/TestServices/WebService.asmx");
To: WebService.set_path("http://test.com/TestServices/WebService.asmx");

?Reference the script in the <ScriptManager>
<asp:ScriptManager ID="MyManager" runat="server">
<Scripts>
<asp:ScriptReference Path="WebServiceDifferentURL.js" />
</Scripts>
</asp:ScriptManager
If you choose to do this, users will get the following message when they click the button letting the user know that they are sending a request to a different site:

Simple Demo
Proxy generation script
When the service request tag does not specify InlineScript = "true", a separate HTTP request is made to the asmx to download the proxy script. This is done using a special URL request syntax as mentioned previously.

http://.../foo.asmx/js

This request returns the proxy generation scripts that instantiate the specific JavaScript proxy objects for foo.asmx. This is done to allow developers to write JavaScript code using namespaces and classes which are not inherently available in JavaScript. This also abstracts the serialization of complex types from the developer. The content type of the returned proxy script is set to "application/x-javascript".

Proxy objects graph corresponding to namespace
The proxy generation script will create a Web Service proxy object corresponding to any Web Service class in foo.asmx that has a server attribute [ScriptService] and contains one or more methods marked with the [WebMethod] attribute.

[Microsoft.Web.Script.Services.ScriptService]
public class PeopleServices : System.Web.Services.WebService {
}
2.No.This is not necessary to call a web service through javascript,which only provides a method to consume web service from the client side.You can call a web service method according to the traditional way.
3.There are a lot of Ajax controls which can consume web service and have ServicePath and Servicemethod properties to specify a web service.This is intellisense.But it is not .js file.
4.Calling Web Services in JavaScript
Now that we've talked about setting up the ScriptManager and how the proxy functionality works, let's take a look at how developers will leverage this technology. We'll look at passing both simple and complex data type and handling errors. During the demos, we'll take a look at the network traffic being passed to and from the server.

"Fire and Forget" Invocation
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();
}

If you want to get the dataset which is returned by?a?web?service,you?can?call?it?according?to?the?traditional?way?and?bind?it?to?asp:GridView.
If?you?would?like?to?consume?some?web?service?methods?through?javascript?from?the?client?side,try?to?use?Ajax?control?toolkit?which?are?useful?for?you.?

Wish the above can help you.

great answer. thanks and regards!

Abort aysnc request when user clicks a menu link on the web page

Hi,

I've got my web page working with ASP.NET AJAX but the problem is when I click a link on pages menu I don't get taken to the new page until the page I'm on has received all the async. data from the server.

So, I need to know how to abort the async. requests when the menu link is clicked so it takes me straight to the newly requested page.


Thanks
Jon

You may want to look at the update progress. I think the at least the older releases had a way to do that there.
Hi,

You can use the following javascript function to abort an async call.

function CancelAsyncPostBack()
{
Sys.WebForms.PageRequestManager.getInstance().abortPostBack();
}

Hope this helps.

Hi,

Just to test this, I added button to my page which calls the Cancel javascript function. After clicking this button I then click one of the menu links and I don't get taken to the new page until the AJAX stuff has finished.

Below provides more information and hopefully clarifies what I'm doing.


1) On page load a javascript function is called which loops through each row in the DataList table and makes an asynchronous call to a webservice method on the server.

2) It takes 10-20 seconds for the server to calculate the details for each request and then return the results to the callback function on the client, where the results get shown in appropriate columns of the DataList table.


I have 10 rows in my table so end up making 10 near simultaneous calls to the webservice on the server. Whilst waiting for the server to finish responding to these requests I click a link on the page and I want to be taken to the new page immediately. As it stands, I have to wait for the server to respond with all the requested data.


So, my questions are:

1) how do I stop the client waiting for the rest of the data so it goes to the new page?

2) Is it possible to tell the webservice on the server to quit working on the problem?

Thanks
Jon



The reason is because of theInternet Explorer's Simultaneous Connections Limit which is 2 by default.
Please refer to this: ?http://weblogs.asp.net/mschwarz/archive/2005/10/20/428047.aspx

speedbird:

?1) how do I stop the client waiting for the rest of the data so it goes to the new page?

2) Is it possible to tell the webservice on the server to quit working on the problem?

As far as I can tell, there isn't a good way to achieve your requirement.

Hello,

Q) how do I stop the client waiting for the rest of the data so it goes to the new page?
A) What you can do is use JavaScript or HTML anchor to redirect the client to a different page.

Sample: HTML Anchor: <a href=URL_Name target="_self">Click to go to different page</a>

JavaScript Function
function Redirect()
{
location.href='http://www.asp.net';
}

<asp:hyperlink id="hlRedirect" Text="Click Link to Go" onclick="Redirect(); return false;" style="cursor: hand;" runat="server" />

Sample URL:http://forums.advancemicrotech.com/threads/thread051507.aspx
Note: The Start Thread button is the same as your webservice doing its job. Once you click Start Thread button, the thread goes to sleep for 10 seconds, same as your webservice doing something on the server. During this time, you can either click the Redirect button that is created with HTML or the ASP Hyperlink ... as shown above ...


Q) Is it possible to tell the webservice on the server to quit working on the problem?
A) No you cannot tell the webservice to quit working while it's doing its job.

Hope these help ... Cheers.

A Simple Atlas Work,but Still have Unknown Error BUG

Simply, i Place a Textbox and a button,when i click the button, it response.write(textbox1.text)
but, when i click the button, it show a java script pop-up and show me Unknown error..

below is the code:

1Default.aspx2<%@dotnet.itags.org. Page Language="VB" AutoEventWireup="true" ValidateRequest="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>34<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">5<html xmlns="http://www.w3.org/1999/xhtml">6<head runat="server">7 <title>ASPNET_Atlas_Testing</title>8</head>9<body>10<form id="form1" runat="server">11<div>12 <atlas:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="True"/>13<!-- This section of the page is wrapped by an UpdatePanel. -->14 <atlas:updatepanel id="up" runat="server" mode="Conditional" rendermode="Inline">15 <triggers>16 <atlas:controleventtrigger controlid="TextBox1" eventname="TextChanged" />17 </triggers>18 <contenttemplate>19 <asp:TextBox ID="TextBox1" runat="server" OnTextChanged="TextBox1_TextChanged"></asp:TextBox><br/>20 </contenttemplate>21 </atlas:updatepanel>2223<!-- This section is also wrapped by an UpdatePanel. -->24 <atlas:updatepanel runat="server" id="up1" mode="Conditional" rendermode="Inline">25 <triggers>26 <atlas:controleventtrigger controlid="Button1" eventname="Click" />27 </triggers>28 <contenttemplate>29 <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click"/>30 </contenttemplate>31 </atlas:updatepanel>32</div>33</form>34</body>35</html>3637
1Default.vb23PartialClass _Default4Inherits System.Web.UI.Page56Protected Sub Button1_Click(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles Button1.Click7 Response.Write(TextBox1.Text)8End Sub910 Protected Sub TextBox1_TextChanged(ByVal senderAs Object,ByVal eAs System.EventArgs)11 Response.Write(TextBox1.Text)12End Sub13End Class1415
Check to make sure your web.config file is setup right and that your dll is in place (/bin) and not corrupt, as I'm not getting a javascript error when I try your code. It also doesn't work as you wrote it, though, and so I tried adding a label to one of the update panels and having the button change its value based on the text prop of the textbox1, and that worked fine. So I suspect that with update panels (this is just a guess) that you can't use Response.Write; whcih would make sense if you conceive of the Response object as passing a whole page rather than just the partial page the update panel is looking for.

Hi,

Remove all response.write statements & replace them with this.page.registerclientscriptblock(script);

Amit Lohogaonkar

mcp,mcad

lohogaonkaramit@.yahoo.com

Wednesday, March 21, 2012

A question of using dollar sign...

I do'nt very clear about the using of dollar sign.

For example:

this._button$delegates =
{
click : Function.createDelegate(this, this._button_onclick)
}
(From AJAX Control toolkit)

or

Namespace.$create_AnimatedUpdatePanelOptions = function nStuff_AnimatedUpdatePanelOptions() { return {}; }
(From Nikhil's sample)

or

$get(DomElementName)
(From AJAX document, I got the meaning of this one.)

Is there any kind person to tell me the difference between those different using of dollar sign?
Thank you very much!

This is done basically for debugging support. You can read the full details inhttp://weblogs.asp.net/bleroy/archive/2007/03/15/what-are-these-foo-bar-baz-functions-in-the-microsoft-ajax-library-files.aspx


The post will be very useful!
Thanks!

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.

A group of PostBackTrigger in my updatepanel

I use a repeater to print out information (hyperlinks) from my database. When you click a hyperlink I want to update a updatepanel.

The problem is that the controlID for each link must be typed in a PostBackTrigger to work perfectly. I can't add PostBackTriggers at run time? Any solutions?

Regards Gustav


Can't you set your updatepanel's mdoe="Always" ?
If I remove my triggers and set UpdateMode="Always" the updatepanel updates without Ajax.

The easiest maybe to handle the hyperlink click event on the server side, and update the desired updatepanel in the click event by the .Update() method.

For handling all hyperlink click event in single event in the server side, and determine which link was clicked: check msdn for handling events in repeater, this is a regular asp.net task not ajax. Search for: "How to: Respond to Button Events in DataList, Repeater, or GridView Items"

A feature for Accordion Control

If I click on the pane, it opens.

If I click again on the same pane, nothing happens.

I'd like to have the pane closed on the second click, and don't open ANY panes.

I looked into the source code, and I could modify it myself, but I'd rather have it inside official release.

Dmitri

Yes, I'd like this too, does anyone know if this is possible to do?

yes, this idea is exactly what I was thinking about as well, I have another idea: possibility to have open more panels (when you have first panel opened and click on second one, instead closing first let it opened and open second too) and maybe some icons (likecollapsible Panel has) common for all panel in accordeon with functionality open/close all panels.I know most of it it is possible do through set ofcollapsible Panels, but maybe should be useful to have it in accordeon as well

Peace,

Milo


Hi everyone,

This is popular enough that it's been listed asissue 1679. It's looking like we're going to do this, although I don't have an estimate on when.

Thanks,
Ted

I have made an accordion with a "header" Pane, which stands out from the ones below it (click to close text or something like that would be easy enough).

The contents of the pane are empty. This is an easy work around until the accordion works as requested.


I want to know the work around as well,

so please tell us how you did that!!


If you can have many panes open at the same time, how is it different to having many CollapsiblePanels?

CAn you provide source of your change?


Seems like this has been fixed already. How to use it??