Having trouble calling a function in my CSHTML page.
In the script of my CSHTML page :
<script type="text/javascript" >
//var sLoggedInUser = <%# GetSession_LoggedInIdUser() %>;
$(document).ready(function () {
alert("dom");
var sLoggedInUser = PageMethods.GetSession_LoggedInUserName();
alert(sLoggedInUser);
});
function btnClick() {
alert("btn click");
}
</script>
'dom' is alerted, button click function works fine, but no value for sLoggedInUser. In my CS page:
protected string GetSession_LoggedInUserName()
{
SessionConfiguration Obj_Configuration = (SessionConfiguration)Session["Configuration"];
return Obj_Configuration.LoggedInUserName;
}
I also tried with :
var sLoggedInUser = <%= PageMethods.GetSession_LoggedInUserName() %>
// var sLoggedInUser = GetSession_LoggedInUserName()