Click here to Skip to main content
15,900,667 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
function CallCRisMacSystem() {
      var userid = document.getElementById('ctl00_hdnuserName').value;
         var myReq = null;
            if (window.XMLHttpRequest) {
                myReq = new XMLHttpRequest();
            }
            else if (window.ActiveXObject) {
                myReq = new ActiveXObject("Microsoft.XMLHTTP");
            }
            if (myReq) {
                var url = "http://172.16.92.3/obcmiswebsite/Services/UpdateInfo.asmx/FindUsers?prefixText=";
                url += userid;
                myReq.open("GET", url, true); //set for async "get"
                myReq.send(null); //execute asynchronous call to web service
                window.open("http://172.16.92.3/DownLoadUpdatedDLL/CRisMacUpdatesUAT.application");

            }
        }


Please help anyone
Thanks
Posted
Updated 19-Mar-14 21:04pm
v2
Comments
Peter Leow 20-Mar-14 3:17am    
Why? JavaScript is client-side, while C# is code-behind.
phil.o 20-Mar-14 3:24am    
This has no sense. Converting from javascript to c# per se is not a goal, it is a (weird) way to a specific goal; as Peter told you, these deal with totally separate concerns. So what is it that you want to achieve, concretely?
Naim_86 20-Mar-14 3:54am    
actualy i want to check user session and then call this funtion so that i want to write on linkbutton click event .
help me please
VICK 20-Mar-14 4:26am    
So where are you stuck during conversion to C#???
Unable to check the session or what??

Do Post your code to get the expert's opinion for quick resolution.
Naim_86 20-Mar-14 4:53am    
<asp:LinkButton ID="lnkCRisMacSystem" CssClass="link" runat="server"
OnClientClick="CallCRisMacSystem()" Font-Bold="True"
onclick="lnkCRisMacSystem_Click" > CRisMac System

if (Session["UserId"] == null)
{
Session.Abandon();
Server.Transfer("login.aspx");
}

<sessionstate cookieless="UseUri" mode="InProc" timeout="10">

Here is code but first execute java script function and then it check. and i want reverse

1 solution

Well As per your quoted comment. You want the reverse. Mean. You want to check the session. and if the session is not null than You want to call the ClientSide function(JavasSCript). RYT?

IF yes!. Dn do have a look at the posted code under Quoted Text.


Quote:
<asp:linkbutton id="lnkCRisMacSystem" cssclass="link" runat="server" xmlns:asp="#unknown">
OnClientClick="CallCRisMacSystem()" Font-Bold="True"
onclick="lnkCRisMacSystem_Click" > CRisMac System

if (Session["UserId"] == null)
{
Session.Abandon();
Server.Transfer("login.aspx");
}



Here is code but first execute java script function and then it check. and i want reverse




C#
if (Session["UserId"] == null)
{
Session.Abandon();
Server.Transfer("login.aspx");
}
else
{
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "ClientFunc", "CallCRisMacSystem();", true);
}



ScriptManager.RegisterStartupScript will be used to call the client side function in the ELSE block, incase the session is not null.

Hope it will help you. :)
 
Share this answer
 

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