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

Wednesday, March 28, 2012

Calling a simple Web Service from an ASPX page

Hi

I created a new Atlas web project, added a new web service and web page using the the code from the Simple.aspx and SimpleService.asmx.

Given I have identical code in the page and ws, I end up with 'Quickstart' is undefined error, on the following line of javascript:

requestSimpleService = Quickstart.Samples.SimpleService.EchoString(
document.getElementById('inputName').value, //params
OnComplete, //Complete event
OnTimeout //Timeout event
);

Any ideas?

It turns out in VS2005, when a new web service is created a code-behind is also created and placed into the App_Code directory. The problem I was getting was becuase the namespace reference was not the same as in the asmx.

Problem solved.


Great! Note that this behavior is optional, so if you prefer you can get the code inline in the asmx file (it's a checkbox on the add dialog).

David

Monday, March 26, 2012

CallBack on ContentPageHolder

Hi everyone,

I have a Master Page called AppMaster.master And I have two aspx pages: Default.aspx and News.aspx.

On my AppMaster.master i have one Menu (top of the page) and Ads (left and right of the page). I have a ContentPlaceHolder in AppMaster. When i click on Home the page refresh and go to /Default.aspx, the same thing for /News.aspx.

I want to refresh only the content of the masterpage using callback or AJAX. I probed two methods but i can't refresh only the content. When i click news on the menu of the master page refresh only the content showing /News.aspx without postback. I used the updatepanel but it does'n work.

Can you help me please? Thanks...Confused

This is your scenario?

1) You have a master page,

2) You have two content pages that use the master page,

3) You want to refresh the UpdatePanel on the content page when someone clicks a link on the Master Page?

Check this out, and if this does not help you then let me know:http://www.ben-rush.net/blog/PermaLink.aspx?guid=d29bafbb-35f5-425e-9105-c1ddaae3b003&dotnet.

...it's possible I don't understand exactly what you're trying to do.


Option 3. I have a Menu with the MenuItemClick method.

Thank you very much...


Option 3. I have a Menu with the MenuItemClick method. It doesn't work because new MenuEventArgs doesn't work :(

Thank you very much...

CAllback Http handler http module

Hi all,

Can anybody tell me how to generate callback.This call back should NOT be in on aspx page .

I this its solution is Http module or Http handler but i dont have idea to implement .Give me some reference and sample code or examples for implementing call back using http handlers or httpmodule

thanks

Could you please describe in more detail what you want? A callback (as in ICallbackEventHandler) that is not on a page does not make sense.


I HAVE A WEB CONTROL CLASS LIBRARY IN WHICH I HAVE A .js FILE ADDED AS RESOURCE FILE . FROM THIS FILE I WANT TO SEND A CALL BACK AS I WANT TO USE "AJAX". BUT AS FAR I KNOW I REQUIRES A .aspx.cs PAGE WHICH I CAN'T ADD IN THE CLASS LIBRARY. HOW WILL I DO THIS TASK.

ANY KIND OF HELP IS APPRECIATED


ICallbackEventtHandler can be implmented in a Controt, it not true that it can be only implmented in a page. For more details of creating controls with ICallbackeventHandler checkout this articlehttp://msdn.microsoft.com/msdnmag/issues/05/01/CuttingEdge/default.aspx

Call WebMethod declared on a DIFFERENT aspx page?

I'd like to expose a WebMethod on an ASPX page and then invoke it from my Atlas page:

<atlas:ScriptManagerrunat="server"ID="scriptManager">

<services>

<atlas:servicereferencepath="MyAspxBasedService.aspx"type="text/javascript"/>

</services>

</atlas:ScriptManager>

Then invoke it. The reason is that I want the full ASPX processing to happen. In short, I want to declaratively create controls on the ASPX page, then render partial pieces of them to be returned back to the Atlas client.

Any help?

Tad

Just as I sent, I noticed that you wanted to call a page method on adifferent page, so clearly PageMethods.YourMethodName() won't work.

Calling a method on a different page is not supported. I'm not convinced that this is desirable; when you call a method on the current page, the point is that the server page gets populated with all the data from the browser, and that your method can make use of it. But if it's a different page, it can only have its clean original state, which seems a lot less useful.

David


Hi Tad,

You don't need to use any servicereference to call a method that's on the page itself. Just mark the method with a [WebMethod] attribute, and call it using the name PageMethods.YourMethodName(...).

David


Thanks David.

I've got a flyout asp:Menu control on my site that is 3 levels deep, which bulks up the page size and is pig slow. I thought about seeing if I could get the same benefits of the control by making it populate on demand. So, my ASPX call will pass a parameter indicating which branch of my menu I need to render (from my database). I would use the menu control to programmatically build the branch and render the html which I'd return from my webservice call. (of course I'd cache it too).

The nice thing about the ASPX page is that I can declaratively define the menu properties and templates.

I suppose I could make an XmlHttpRequest directly to the ASPX and pass query string params, but that seems soooooo YESTERDAY!

I'm just foolin' around. Any ideas before I go off and just build my own lightweight flyout control?

Tad


Why not use a Web Service that provides your site navigation menu data that takes, as input, information indicating the current branch that the page is on? Atlas is definitely designed for dealing with that type of scenario, and the 'pig slow' effect can be mitigated by having bits of your menu populated dynamically asynchronously using the Web Service invocation.

Obviously if you're tied to only using an ASPx page, then thats that...but one of the first things I did with Atlas was whip out a dynamically-generated site navigator that was powered by a Web Service. I was really impressed with it.


I wouldn't attempt that myself. Plus, I don't think a flyout menu is the right control for on-demand population (which is exactly why we didn't include the feature in the first place). Imagine what will hapen if the user flies his mouse cursor over the menu (which he'll necessarily do unvoluntarily): tens of requests sent to the server at the same time. Ugly.

Developing a lighter menu with fewer features but with focus on CSS without inline styles is probably a much better option. I was thinking of doing that when I have some time (which probably means not in the next few weeks).


Sure, that's a good point, and even without using a web service and dynamic population, reducing the depth of the menu and starting at the current hierarchy level can help considerably.

A combination of a menu and a SiteMapPath can give a good navigation UI without going too fancy.

About what you describe, the thing is that the menu does not support populate on demand. A treeView would do the trick, but that may not be the UI you want (although the TreeView appearance can be brought close to that of a menu with the exception of the fly-outs).

Call web service by Javascript in Logon.aspx

I used FormsAuthentication in my ajax-enabled website. Now I wanna call web service (in website) on client-side in Logon.aspx. But I always got an error that is like:

"WebService1" is undifined. (WebService1 is class name in the webservice)

I guess that's because ScriptManager will initialize webservice only after FormsAuthentication. Is this true? I can call webservice client-side in another aspx page.

If no any way for this, I have to give up FormsAuthentication.

Could you show us your code / markup?

You need to authorize anonymous users to access the web service. This can be done in many ways. The easiest way is to add an entry to the web.config file:

<location path="WebService1.asmx">
<system.web>
<authorization>
<allow users="?"/>
</authorization>
</system.web>
</location>


Thank you, Rama. It works.

Saturday, March 24, 2012

Call Client script from Server Side

Hi All,

I want to call javascript function from server side when I am using updatePanel.

Actual Scenario is as follows:

I have one form A.aspx in which I have a button named "btn_display" and this button is in Update Panel.

Now I call server side function on btn_display_click and from that server side function i want to call javascript function.

How should I proceed??

Plz help

Thanks in advance

HI,
You can use registerclientscriptblock to allow the client script to work from a serverside event

Hello, RegisterStartupScript is more appropriate for this.

Regards. -LV