如何在Update Panel中使用RedirectFromLoginPage方法或使用Rad Ajax [英] How to use RedirectFromLoginPage method inside Update Panel or using Rad Ajax

查看:95
本文介绍了如何在Update Panel中使用RedirectFromLoginPage方法或使用Rad Ajax的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,



基本上我的问题有两个部分,



1)如何通过returnurl with response.redirect(login.aspx),目前我正在使用这样的东西



  string  returnUrl =  ?ReturnUrl = + Request.RawUrl; 
Response.Redirect( 〜/ login.aspx + returnUrl + n);





2)在登录页面我正在使用Ajax,所以如果用户输入了错误的数据,则会显示错误消息完全回发,但现在问题是当用户输入有效凭据时,以下代码片段不起作用,换句话说如何重定向到更新面板内的其他页面?谢谢





 FormsAuthentication.RedirectFromLoginPage(txtUsername.Text,); 

解决方案

以下是您可以通过其重定向页面的JavaScript代码可以使用Ajax使用服务器端代码重定向页面。唯一的挑战是在成功登录后执行此代码。实现此目的的一种方法是在更新面板内创建Literal控件,并在成功登录后将下面提到的JavaScript字符串分配给Literal控件。 

我无法测试此代码。我不确定它是否适合你,但我只是想给你一个想法。

< script > ; window.location.href = 的Login.aspx


Hey,

Basically my question has two parts,

1) how to pass returnurl with response.redirect(login.aspx), currently I''m using something like this

string returnUrl = "?ReturnUrl=" + Request.RawUrl;
Response.Redirect("~/login.aspx" + returnUrl+n);



2) In login page I''m using Ajax, so incase if the user enters wrong data, the error message is shown without a full postback, but now the problem is when the user enters valid credentials the following code snippet doesn''t work, in other words how to redirect to anther page inside update panel? Thanks


FormsAuthentication.RedirectFromLoginPage(txtUsername.Text, true);

解决方案

Below is the JavaScript code through which you can redirect page as its not possible to redirect page using server side code using Ajax.The only challenge is to make this code execute after successful login. One way to achieve this create Literal control  inside update-panel and after successful login assign below mentioned JavaScript string to the Literal control.

I was not able to test this code. I am not sure if its going to work for you, but I just want to give you an idea.

<script>window.location.href="Login.aspx"


这篇关于如何在Update Panel中使用RedirectFromLoginPage方法或使用Rad Ajax的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆