Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to call a class from a cs file to update or save the session expired in database?
    text
    copied!<p>I have a class function as following &amp; I would like to use this class to be called into my master page. Then, doing login &amp; logout time saved of the page into my database.</p> <pre><code>namespace LogInLogOut { public partial class LogInLogOut : System.Web.UI.Page { public static void updateLogoutTime(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>Here is the code in master page for doing popup message, but I have no idea to write the call function for calling the upper class into my master page. Hope anyone can assist me for this problem. Thank you.</p> <pre><code>protected void Page_Load(object sender, EventArgs e) { string csname = "timeoutWarning"; Type cstype = this.GetType(); if (!Page.ClientScript.IsStartupScriptRegistered(cstype, csname)) { string strconfirm = "&lt;script&gt;" + "window.setTimeout('SessionTimeOutHandler()', 10000);" + "function SessionTimeOutHandler() { " + "alert('Your login session is expired');" + "function(){ update(document.LogInLogOut('lblUserName.Text', 'lblComputerName.Text', 'UR')); } " + "window.location='../login.aspx';" + " } &lt;/script&gt;"; Page.ClientScript.RegisterStartupScript(cstype, csname, strconfirm, false); } } </code></pre>
 

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