简体   繁体   中英

How to pass values from an aspx page to HTML page?

I've a Login.aspx page. After successfully logging in, I'm redirecting it to Welcome.html page located in another project. Now, I want a jquery modal box to appear on HTML page containing message "Welcome USERNAME" when user logs in successfully. How can I retrieve USERNAME entered on Login.aspx page? I think JQuery is the solution for this, but I've no idea how to implement this. Please help.

you can pass it in url

like Welcome.html?username=Prateek

in Welcome.html use jquery to get url parameter value ( username )

 <script >
    $(document).ready(function () {
    var x = getParameterByName("username"); ///get url parameter value
    alert("username : " + x);
    function getParameterByName(name) {
            name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
            var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
                results = regex.exec(location.search);
            return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
        }
    });
</script>

Make the welcome.html page an aspx (if you are able to do so) and then you can use the User object which I believe is called like this:

HttpContext.Current.User.Identity.Name

Here are the Msdn references:

http://msdn.microsoft.com/en-us/library/system.web.httpcontext.user.aspx

http://msdn.microsoft.com/en-us/library/system.web.ui.page.user.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM