Click here to Skip to main content
15,889,931 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have master page where login box is made which displays as popup using jquery
and button to login...

when i use asp:button , onclick is never called if popupbox asp:button is clicked..

also , if i use normal button, and onclick in jquery, i call ajax post , and call a web method inside default.aspx

if i use this, how to change text for login in master page ....from login to logoff , welcome .....
Posted
Comments
Suk@nta 15-Jan-14 3:53am    
It will be better if u write your code here and we can analyse your code.
maulikshah1990 15-Jan-14 4:10am    
my html code in master page is



on the above click, a pop up box with below html code

<input class="loginName required" type="text" id="loginname" value="Username" name="loginName" />
<input class="loginPass required" type="password" id="loginpassword" value="Password" name="loginPass" />

<input type="submit" value="LOG IN" id="LoginBtnValue"/>

on login click

function GetLoginDetails(UserName,UserPassword)
{
//alert(UserName+UserPassword);
var returnurl = window.location.href;

$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "Default.aspx/GetLoginDetails",
data: "{'UserName':'" +UserName+ "'," + "'UserPassword':'"+UserPassword +"','returnurl':'"+returnurl+"'}",
success: function(data) {
var theHtml = data.d;

if(data.d=="loginerror")
{
alert('Username or password is incorrect');
}
else
{
window.location.href = data.d;
}
},
error: function(xhr, textStatus, errorThrown) {
alert("Login FAIL: " + xhr + " " + textStatus + " " + errorThrown);
}
});

}

with values

and in default.aspx.cs ,
web method like

[WebMethod]
public static string GetLoginDetails(string UserName, string UserPassword,string returnurl)
{


}

In this i want to [WebMethod]
public static string GetLoginDetails(string UserName, string UserPassword,string returnurl)
{

}


what i want is to change master page text login to logoff with name (for exp, logoff , welcome name)

how to get master page control in content page web method
joginder-banger 15-Jan-14 4:25am    
hi friend i try this type of but can't be success. if you success plz send me a complete project.

1 solution

Don't change text in Web Method. You can easily do that in Success Block.
JavaScript
success: function(data) {
    var theHtml = data.d;

    if(data.d=="loginerror")
    {
        alert('Username or password is incorrect');
    }
    else
    {
        // User Authenticated, so try to change Text here something like below...
        document.getElementById('LoginBtnValue').value = "Logoff";

        //Make sure the ID rendered is, else try the below code...
        //document.getElementById('<%=LoginBtnValue.ClientID %>').value= "Logoff";

        window.location.href = data.d;
    }
},



[Update after OP's Reply]

Quote:

I have <a href="3" class="login">login

now i want to make login as logoff and not button,

but from jquery , if i do this , it will refresh page and keep original values and not new value which we give
Okay do one thing. If page refreshes, it will show "Login" again. To resolve that, you can do one thing.

Pass one QueryString along with the data.d. Let's try the below...
JavaScript
if(data.d=="loginerror")
{
   alert('Username or password is incorrect');
}
else
{
    window.location.href = data.d + "?loginText=Logoff";
}

Provided data.d is a Page URL. So, we have one QueryString. Now we just need to read it on that Page Load and assign that to the Login link by jQuery/JavaScript.
 
Share this answer
 
v2
Comments
maulikshah1990 15-Jan-14 5:47am    
I have <a href="3" class="login">login

now i want to make login as logoff and not button,

but from jquery , if i do this , it will refresh page and keep original values and not new value which we give
Okay do one thing. If page refreshes, it will show Login again. To resolve that, you can do one thing.

Pass one QueryString along with the "data.d". Let's try the below...

if(data.d=="loginerror")
{
alert('Username or password is incorrect');
}
else
{
window.location.href = data.d + "?loginText=Logoff";
}

Provided data.d is a Page URL. So, we have one QueryString. Now we just need to read it on that Page Load and assign that to the Login link by jQuery/JavaScript.

Do you understand my point? Is it clear?
maulikshah1990 15-Jan-14 6:28am    
ok...this i taught first..i will do this ..also how to maintain session using above web method .
For Session, you have to set like below...

[WebMethod(EnableSession=true)]

Then you can use Sessions inside the Web Method.

Please accept this answer, if it has helped you in any way.
This will help others to find the answer in one go and you will also be awarded with some points for this action...

Thanks,
Tadit
I have also updated the answer, so please accept that and up-vote. :)

Thanks,
Tadit

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900