Note that there are some explanatory texts on larger screens.

plurals
  1. POcalling an asp.net function with jquery or ajax
    primarykey
    data
    text
    <p>I am creationg an admin page, and I need to redirect the page after a few seconds if the user is not allowed to be there. there is supposed to be a session created when the admin has loged in, and i want to use jquery to check if the session exists.</p> <p>here is the c# code:</p> <pre><code>protected void Page_Load(object sender, EventArgs e) { if ((string)Session["admin"] == null) { mainF.InnerHtml = "&lt;div id='inner' style='margin-left:370px; margin-top:80px;font: 0.92em arial,sans-serif;word-spacing: 2px;font-weight: bold;'&gt;Your Are Not Supposed To Be Here.&lt;/div&gt;"; } } public bool checkIfAllowed() { bool isIt = false; if ((string)Session["admin"] != null &amp;&amp; (string)Session["admin"] != "") { isIt = true; } return isIt; } </code></pre> <p>so basicly I thought that I can somehow use jquery to call the checkIfAllowed() function to check whether the session exists or not, but i dont know how.</p> <p>this is what i have:</p> <pre><code>if (!checkIfAllowed() /*which of course doesn't work*/) { var inter = setInterval(function () { window.location.replace("http://www.google.com"); }, 3000); } else { clearInterval(inter); } </code></pre> <p>there probably are other ways to do this, if you have a some solution please tell me. i guess i can also redirect the page with asp.net but it didn't work the first time. i also tried writing </p> <pre><code>$("#inner").html != null &amp;&amp; $("#inner").html != "" </code></pre> <p>in the if() statement in the jquery, because #inner html is changing on pageLoad in asp.net.</p> <p>thanks =]</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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