Showing posts with label examples. Show all posts
Showing posts with label examples. Show all posts

Monday, March 26, 2012

integration with asp.net services

Is there any documentation or examples online for creating atlas
applications that use the asp.net services?

Wally

--
Wallace B. McClure
"The Harder I Work, the Luckier I Get."
Listen to "The ASP.NET Podcast" at http://www.aspnetpodcast.com/
Database Award: http://url123.com/vc3er
Microsoft MVP - Visual Developer ASP/ASP.NET
AspInsider
"AJAX for ASP.NET" Coming Soon!
ADO.NET Book: http://url123.com/vc2bu
865-693-3004
118 Durwood Rd.
Knoxville, TN 37922
http://www.scalabledevelopment.com/
Blog: http://weblogs.asp.net/wallym/

Have you looked at theservices quickstarts? They have examples on doing this.

David


I have not seen any examples on integrating with things like membership,
authentication, and authorization. Do you have a URL?

Wally

wrote in message news:1196178@.66.129.67.202...
> Have you looked at the services quickstarts? They have examples on doing
> this.
>
> David
>
I have not seen any examples on integrating with things like membership,
authentication, and authorization. Do you have a URL?

Wally

wrote in message news:1196178@.66.129.67.202...
> Have you looked at the services quickstarts? They have examples on doing
> this.
>
> David
>
Sorry, I misunderstood your reference to "asp.net services" as meaning calling asmx asp.net web services from script. Let me check whether there is a sample relating to auth and membership.

The current integration with Membership and Forms authentication is limited to two methods on Web.Services.AuthenticationSerivce:

login

validateUser

The first method accepts a username, password and clientside event hookups for completion, errors and timeouts. Back on the server it validates the credentials with thedefault Membership provider. Assuming the call to ValidateUser succeeds, the "login" method returns a forms authentication cookie by calling FormsAuthentication.SetCookie(). When the call to ValidateUser succeeds, the result from "login" is true - failed credentials result in a "false" return value and no cookie.

The code for this looks something like:

function OnSubmitLogin() {
//Use the built in Atlas authentication service to make a call to the server.
//This call will verify credentials, and if the credentials are good, the server will
//issue a forms authentication cookie.
Web.Services.AuthenticationService.login(username.value, password.value, OnLoginComplete);
return false;
}

//The asynchronous completion event where you process the result of calling the server
function OnLoginComplete(result) {
password.value = '';

//On success there will be a forms authentication cookie in the browser.
if (result) {
username.value = '';
textLoggedIn.style.visibility = "visible";
textNotLoggedIn.style.visibility = "hidden";

buttonLoginLogout.innerText = "Click me to logout!";
buttonLoginLogout.onclick = OnSubmitLogout;
}
else {
textLoggedIn.style.visibility = "hidden";
textNotLoggedIn.style.visibility = "visible";
}
}

The "validateUser" works similarly to "login", but no forms auth cookie is set.


Awesome info. I had been scanning through the Atlas.js file and I was
trying to understand the difference between login and validateUser. That
info really helps.

Wally

wrote in message news:1197028@.66.129.67.202...
> The current integration with Membership and Forms authentication is
> limited to two methods on Web.Services.AuthenticationSerivce:
>
> login
>
> validateUser
>
> The first method accepts a username, password and clientside event hookups
> for completion, errors and timeouts. Back on the server it validates the
> credentials with the default Membership provider. Assuming the call to
> ValidateUser succeeds, the "login" method returns a forms authentication
> cookie by calling FormsAuthentication.SetCookie(). When the call to
> ValidateUser succeeds, the result from "login" is true - failed
> credentials result in a "false" return value and no cookie.
>
> The code for this looks something like:
>
> function OnSubmitLogin() {
> //Use the built in Atlas authentication service to make a call to the
> server.
> //This call will verify credentials, and if the credentials are good,
> the server will
> //issue a forms authentication cookie.
> Web.Services.AuthenticationService.login(username.value,
> password.value, OnLoginComplete);
> return false;
> }
>
> //The asynchronous completion event where you process the result of
> calling the server
> function OnLoginComplete(result) {
> password.value = '';
>
> //On success there will be a forms authentication cookie in the
> browser.
> if (result) {
> username.value = '';
> textLoggedIn.style.visibility = "visible";
> textNotLoggedIn.style.visibility = "hidden";
>
> buttonLoginLogout.innerText = "Click me to logout!";
> buttonLoginLogout.onclick = OnSubmitLogout;
> }
> else {
> textLoggedIn.style.visibility = "hidden";
> textNotLoggedIn.style.visibility = "visible";
> }
> }
>
> The "validateUser" works similarly to "login", but no forms auth cookie is
> set.
>
No problem. I had hoped that there was something I was missing in the
quickstarts. :-)

Wally

wrote in message news:1196977@.66.129.67.202...
> Sorry, I misunderstood your reference to "asp.net services" as meaning
> calling asmx asp.net web services from script. Let me check whether there
> is a sample relating to auth and membership.
>

Saturday, March 24, 2012

Invoking the ModalPopupExtender from a ListBox

I would like to know if it is possible to invoke the ModalPopupExtender by making a choice in a ListBox. All of the posts and examples I can find appear to use a button to invoke the control. My need is to invoke the control only when a particular selection is made in the ListBox. In my case, there are 4 choices in the ListBox, but I only want the Popup to show when #4 is selected.

As a follow-up, if this cannot be done, is there any work-around that will make the user think this is what happens. In other words, the Popup will appear when they make the particular selection in the ListBox, even if the program had to do something else to make it happen.

This seems like it should be a simple thing to do, but I cannot figure it out (I am new to AJAX and the Toolkit, and still trying to get a good grasp of them).

Any help will be greatly appreciated.

The individual ListItem will not have an ID that the ModalPopupExtender can target. You instead have a hidden input that the ModalPopupExtender targets, set the BehaviorID on the ModalPopup and call show and hide when the ListBox selected index is changed and is equal to the 3. You can hook up the onchange event handler on page load.


kirtid,

I appreciate your answer, and I follow the logic of it. However, you give me far too much credit for understanding how to implement your solution. When I mentioned that I was new to AJAX, I should have probably said (in the interests of full disclosure) that I am new to client-side programming and/or javascript.

I have dropped an html input (text) control onto my page, but the only way I can seem to get the ListBox SelectedIndex into it is to wrap it in an UpdatePanel and use the listbox as a trigger. I have set the BehaviorID in the Extender, but I can't seem to get the ModalPopup to pay attention to my input box. My attempt at the onchange function (for entertainment purposes) looks like this:

function Text1_onchange() {

If (Text1.value="3") {

$find("showPopUp").show()

}

else

{

$find("showPopUp").hide()

}

}

Even if by some miracle this will work, I am unsure how to wire it up.

I would appreciate any hand holding you can provide. I figure I won't learn anything if I don't ask those who know.


In the List element add a client side handler to the changed event:http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/objects/option.asp.

Something like this.

<

bodyonclick="DoSomething()"><scripttype="text/javascript">

function DoSomething() {var listBox = $get('listBox1');

$addHandler(listBox,

'change', ShowModalPopup());

}

function ShowModalPopup() {var listBox = $get('listBox1');var modalPopup = $find('modalBehavior1');var index = listBox.selectedIndex;if ( index == 1) {

modalPopup.show();

}

returnfalse;

}

</script><formid="form1"runat="server"><asp:ScriptManagerrunat="server"></asp:ScriptManager><div><asp:Buttonrunat="server"ID="btn1"Visible="false"/><ajaxToolkit:ModalPopupExtenderID="ModalPopupExtender1"runat="server"TargetControlID="btn1"PopupControlID="DropPanel"DropShadow="true"BehaviorID="modalBehavior1"></ajaxToolkit:ModalPopupExtender><asp:ListBoxrunat="server"ID="listBox1"><asp:ListItem>Foo</asp:ListItem><asp:ListItem>Bar</asp:ListItem><asp:ListItem>Baz</asp:ListItem></asp:ListBox>


kirtid, I've got it working.

Thanks for your help

Invoking WCF web services from client script with MS Ajax RC1

Hello,

I've read through the Ajax documentation which shows some examples of invoking .asmx web services from client code but I couldn't find any information about doing the same with .svc WCF web services. Is this supported in the current Release Candidate of Ajax? If not, is this planned for future releases?

Thanks for your time.

No, svc is not currently supported. However it will be supported in upcoming "Orcas" release. Read ithere and search for "Support for WCF Web Services"

I'm intested by calling a wcf services with ajax

could anyone tell me which version of ajax let me use .svc files and how ? sinc the docs on the web are gone ..


thanks in advance :)