|
Hi All,
I've been trying to put to work the session timeout code from Eric Pascarello site:
http://www.pascarello.com/AjaxSessionTimer.aspx[^]
The problem I'm having it that
if(reqXML.responseText.indexOf("Session Updated - Server Time:") == 0) is always true, even when the session has expired. I added
<%@ OutputCache Location="None" VaryByParam="None" %> to the AjaxSessionUpdate.aspx page but still the if statement is true. Each time the "Confirm" button is pressed a new time is returned.
Does anyone know why this if statement never returns false when the session has expired?
Thank you,
Mel
|
|
|
|
|
This is the code of AjaxSessionUpdate.aspx.vb:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Response.ContentType = "text/html"
Response.Write("Session Updated - Server Time:" & Date.Now.ToString)
End Sub
Calling this page will always yield a string starting with "Session Updated - Server Time:" and thus indexOf will always yield 0. This means the string was found at position 0 the start if the string.
What did your expect?
|
|
|
|
|
Thank you for your quick reply.
Good question, I expected that the req.responseText (strDoc) wouldn't include the "Session Updated - Server Time:" string. I thought AjaxSessionUpdate.aspx would only be called if the session was open, because if the session was closed wouldn't
if(this.req)
in net.js be false and therefore
this.req.open(method,url,true)
(where the url is AjaxSessionUpdate.aspx) wouldn't be called?
If AjaxSessionUpdate.aspx is always called then the session would never be shown as expired in Eric's code and the message "Warning your session has already timed out!" wouldn't be shown, which defeats the object of the code.
Please let me know if there is a way for me to treak the code in order to get it working as expected.
Thank you again,
Mel
|
|
|
|
|
Does anyone have any thoughts on this?
Thank you,
Mel
|
|
|
|
|
function ProcessAction() {
PageMethods.CheckSessionExpiration(OnCheckSessionExpirationComplete, OnCallError);
if (IsLogin == true) {
alert("Inside the Function");
var txtNote = $("[id$=txtNote]").val();
var txtIdentNo = $("[id$=txtIdentNo]").val();
var sIdentNo = "";
DisableControls();
CleanIdentNoList();
if (ValidFields()) {
gAction = $("[id$=cmbAction]").val();
gNote = txtNote;
sIdentNo = jQuery.trim(txtIdentNo);
gMSISDNList = sIdentNo.split("\n");
gMSISDNIndex = -1;
ProcessNextItem();
}
else {
EnableControls();
}
}
else {
window.location = "Login.aspx";
}
}
and i have a Callback function defined like this
function OnCheckSessionExpirationComplete(result,methodName) {
if (result == false) {
IsLogin = false;
}
else {
IsLogin = true;
}
}
Now the "IsLogin" variable is a Global variable defined like this
var IsLogin = true;
What i want to do is to redirect the user if the Session is null, as you can see i have added the line
System.Web.HttpContext.Current.Session["CurrentLoginUser"] = null;
For testing Purpose , but my problem is is that, even if its null, the
alert("Inside the Function");
is fired, what i am i doing wrong.
THanks
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
PageMethods are asynchronous, meaning that PageMethods.CheckSessionExpiration will be executed and it will proceed to the next statement if (IsLogin == true) . Move this logic to the OnCheckSessionExpirationComplete method
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Thanks that saved my life
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Hi,
I have been working on a table which user can select some cells. After selection data
will be sent to server to process.
i want to select district cells, but htmls own select mechanism works line-base.
So, i want to enable/disable multiselecting a table's cells. Is it possible?
i run into a similar feature in html5 but my work is on earlier version.
when table cells are empty, multiselect does not happen. In addition, it tries to drag and drop
block elements.
Thank you in advance
asbasir
|
|
|
|
|
Hi,
I have another javascript on a poppup window in asp.net to return the value back to the parent .
but it gives me an error: opener.document is null or not an object.
opener.document.getElementById("TextBox1").value = "hello";
I even ammended the main parent javascript so as to open this popup as a return value back to a variable.
any help will be highly appreciated.
Thanks
|
|
|
|
|
The error message seems quite clear: opener.document is not an object, that is it has not been initialised to point at a valid object.
I must get a clever new signature for 2011.
|
|
|
|
|
Not sure what you're doing...I've barely scratched the surface of javascript...but you say you're using a MasterPage.
That being the case, "TextBox1" won't be the ID of the control. It will be more like "ctl00_MainContentPlaceHolder_TextBox1" or similar.
View the source of your webpage when it's running to find the runtime name and see if that helps.
|
|
|
|
|
Hello,
I have a simple menu bar base on a ul li list with embedded hyperlinks.
<ul>
<li id="menuHome"><a href="index.html" onMouseOver="setMenu('menuHome')" >Home</a></li>
<li id="menuResults"><a href="results.htm">Results</a></li>
<li id="menuEvents"><a href="events.htm">Events</a></li>
</ul>
I have set the CSS properties such as
#menuHome {
background-color: #CCC;
color: #000;
}
#navleft ul {
list-style: none;
padding: 0;
margin: 0 0 5px 0 ;
text-align: left;
}
#navleft li {
margin: 5px 0;
line-height: 23px;
}
#navleft li a {
text-decoration: none;
padding-left: 9px;
display: block;
width: 140px;
}
My Java script is quite basic
function setMenu( id )
{
var e = document.getElementById(id);
e.style.backgroundColor = 0x666666;
e.style.color = 0xFFFFFF;
}
My goal is to basically have a vertical menu bar that can be used for multiple webpages, so that after the user clicks on it, it will change the background color and text to a different color, so that it is apparent which page the user is on.
(I realize that I'm using the mouse hover for testing, it stops the page from reloading every time I test it).
The problem that I am having, if my understanding is corrent is that the tag that I pass in the jave call is bond to the "li" element of the menu list, the background color changes quite fine, but, I can not seem to be able to access the color property of the "a href" tag to change the text from black to white.
using the e.style example above how would to "Cast it" to the a reference?
Thank you in advance.
|
|
|
|
|
Hi All,
I am having a script file which begins with the following statement:
var ABC = ABC || {};
This is the very first line of the Java Script file, while the remaining is understandable.
Can anyone please tell me what does this line means.
I am unable to understand the meaning of it
Thanks
|
|
|
|
|
Let me reply my Question:
The following line creates namespace in Java script:
var ABC = ABC || {};
It says if there is a class called ABC create a namespace of it, otherwise create a blank namespace.
Hope this may help others for understanding.
|
|
|
|
|
Umair Feroze wrote: It says if there is a class called ABC create a namespace of it, otherwise create a blank namespace.
No, it doesn't create a namespace, because JavaScript doesn't have namespaces; and it does not look for a class as JavaScript does not have classes.
It leaves abc as it is if it is an expression whose Boolean value is true e.g. is a non-zero value, a non-empty string, true, a function, or an object (including an array, even if empty). If it is not a true value, it replaces it with an empty object.
This is a common idion for defining a variable to hold a context (not a JavaScript concept) without accidentally overwriting it if it is already in use. It is better than simply doing var abc = { }; because any properties in the object will be retained.
Technically, it is bad JavaScript because var creates a variable. The appearance of it on the right hand side of an expression when defining it in the left hand side could (in theory) end up using it between the time it is defined and the time it is initialised.
I'd rather do ...
if (typeof abc != 'object')
var abc = { };
although it is questionable as to whether this is valid or not as var s are 'hitched' so it is equivalent to
var abc;
if (typeof abc != 'object')
abc = { };
but you can get away with it because varing a variable that already exists in the current scope has no effect.
|
|
|
|
|
|
Defining variables to hold other methods and properties to minimise the pollution of the global scope is a very well established technique. This technique emulates some of the key features of namespaces in other languages. I use this method in my own code and add comments saying that it is creating a namespace; but that does not make it a namespace, any more that if I commented it as being a Space Shuttle would make it a Space Shuttle; they are still just variables that have properties attached to them.
Compare, in some fictitious language that has 'real' namespaces:
namespace Namespace1
{
helloWorld: 'Hello, World'
}
alert(Namespace1.helloWorld);
Namespace1 = false;
alert(Namespace1.helloWorld);
against JavaScript:
var Namespace1 =
{
helloWorld: 'Hello, World'
}
alert(Namespace1.helloWorld);
Namespace1 = false;
alert(Namespace1.helloWorld);
|
|
|
|
|
You are comparing apples and oranges. What is your point? You made the statement "because JavaScript doesn't have namespaces", to which I replied, "Not quite correct". I did not say it does have namespaces, but rather a facsimile within the constraints of the language. To say it does not, or does not support the construct, is false and misleading.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
How can I initailize array data to variable in JQuery. I want to initialize data from server-side instead of such as the following one.
var myVariable = ["ActionScript", "AppleScript", "Asp", "Scheme"];
-------------------------------------------------------------------
IN SERVER SIDE (cs file)
[System.Web.Services.WebMethod]
public static string MyFunction()
{
// This function return like this string array "ActionScript", "AppleScript", "Asp"....
// Return What? string array or string and how?
}
-------------------------------------------------------------------
I WANT TO CATCH STRING ARRAY ON ASPX (Callback)
<script type="text/javascript">
$(function () {
$.ajax({
type: "POST",
url: "AutoComplete.aspx/MyFunction",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
????? how can I initialize data
var result = WHAT I DO...
Thanks....
modified on Tuesday, January 18, 2011 6:25 AM
|
|
|
|
|
How to do zoom in and zoom out for entire page in all browser. I know it can be done by pressing ctrl + key and ctrl - key. I want code in javascript.
Niladri
|
|
|
|
|
As far as im aware, there is no client-side scripting ability to control the browser zoom capability.
You could design your page in such a way that text/image/other visible element sizes could be controlled with Javascript, but there is no simple 1 line answer to this.
|
|
|
|
|
This is a feature of the browser itself, not JavaScript.
niladri03 wrote: I want code in javascript.
This is very rude. Don't just ask/demand code, we are not rent-a-coders. Show what you have tried and ask a specific question about what you need help with.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Why not put a wrapper round your whole page that has css properties of your page width/height and text size and image size etc. and then just adjust those values using javascript
|
|
|
|
|
I believe you you meant to reply to the OP not me. Nice idea but impractical and doesn't work as you think it does. There is a difference between enlarging an image and actually zooming the rendered output.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Oh yeah sorry and what is the difference? If all he wants to do is zoom the page then if you zoom in and make everything bigger it will be the same as zooming (scroll bars will give the desired scroll effect) and zooming out everything becomes smaller...where's the problem? If it was just zooming the individual image i'd see your point but as it's part of the whole page there isn't actually a difference, is there?
|
|
|
|