Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You cannot call a server function like that in you javascript code.</p> <p>To call a server function, you have to send a request to the server first. This is usually a Postback in asp.net.</p> <p>If you do want to call a function like that, you have to mark it as a <code>WebMethod</code>. Asp.net will hide all the js that is needed to call the function. </p> <p>This blog on <a href="http://geekswithblogs.net/frankw/archive/2008/03/13/asp.net-ajax-callbacks-to-web-methods-in-aspx-pages.aspx" rel="nofollow">WebMethods</a> will get you started.</p> <p>Your code should look like this:</p> <pre><code> [System.Web.Services.WebMethod()] [System.Web.Script.Services.ScriptMethod()] public void LogoutTime(string username, string pcname, string module) { String connectionString = ConfigurationManager.ConnectionStrings["VSConfigConnectionString"].ConnectionString; SqlConnection connection = new SqlConnection(connectionString); SqlCommand cmd = new SqlCommand("UPDATE [Access] set LogOutDate = '" + DateTime.Today.ToString("dd/MM/yyyy") + "', LogOutTime = '" + DateTime.Now.ToString("HH:mm:ss") + "' WHERE LoginID ='" + username + "' AND ModuleID = '" + module + "' AND comptname ='" + pcname + "' AND LogOutDate= ' '", connection); cmd.Connection.Open(); cmd.ExecuteNonQuery(); cmd.Connection.Close(); cmd.Connection.Dispose(); } </code></pre> <p>You can now call this function in javascript using <code>PageMethods</code></p> <pre><code>PageMethods.LogoutTime('lblUserName.Text', 'lblComputerName.Text', 'UR', update); </code></pre> <p>You should put that function in your master page if you want it on all pages, not in a separate page.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload