State Management in ASP.NET...
Cookie Munging
------------------
You may wish to configure your applications to use session state without relying on cookies. There could be several reasons for this:
You need to support old browser types that do not support cookies.
You wish to cater for people who have chosen to disable cookie support within their browser.
Certain types of domain name redirection mean that cookies / conventional state management will not work.
Cookie munging causes information regarding the session state id to be added to URL information. Thus the link between client and session data on the server is maintained.
It is simply enabled, as follows:
If you change your web.config file to the above and then view a page which uses both the session object and postback you’ll see ASP.Net has inserted some extra information in the URL of the page. This extra information represents the session ID.
Cookie munging certainly does the job in instances where it is required but should be avoided where it is not, as it is insecure being susceptible to manual manipulation of the URL string.
ViewState...
1) Introducing ViewState
2) Postback and non-postback controls
3) What can you store in ViewState?
4) Protecting ViewState
5) Encrypting the ViewState
6) ViewState and Performance
7) Session State or ViewState?
Netscape 3+ supports the image objects onError method:
img src="http://www.anywhere.com/myimage.gif" height="100" width="100" onError="alert('Image missing')"
==============================================
You can also use the Image() object to test for the existence of a generic image (or any number of images) without ever displaying them on the page:
function testImage(URL) {
var tester=new Image();
tester.onLoad=isGood;
tester.onError=isBad;
tester.src=URL;
}
function isGood() {
alert('That image exists!');
}
function isBad() {
alert('That image does no exist!');
}
Q52 How do I check if an image file exists?:
"You can also use the Image() object to test for the existence of a generic image (or any number of images) without ever displaying them on the page:
"
While trying to get number only input (both int and decimal), this is what I came up with :-
The idea is that one has to handle the KeyPress event and selectively allow/disallow characters as they are pressed.
C# code for KeyPress event handler :-
void txtNumericTextBox_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
// **************************** The strategy ******************************
//
// we have to allow backspace character, only 'one' '.' in the whole string
// and numeric digits only
//
// ************************************************************************
// allow backspace
if (e.KeyChar == '\b'){
return;
}
// allow only one '.' in the entire text
if (e.KeyChar == '.') {
// check if there is already a '.' char in the text
if (textBox.Text.IndexOf('.') > -1) {
// we already have a '.', so don't allow another '.'
e.Handled = true;
}
return;
}
// the rest of the key, 'disallow' if they are non-digit i.e. 0-9
if (!Char.IsDigit(e.KeyChar)) {
e.Handled = true;
}
}
// here the key thing is e.Handled = true, this basically says that the default key processing should not
// be performed.