Thursday, January 13, 2011

asp.net ajaxtoolkit modalpopupextender open server side and cleint Side

Following code will help for how to open ajaxtoolkit modalpopupextender

how it can open via server side code (c#) or cleient Side code

javascript
==========
var launch = false;
function launchModal() {
launch = true;
}

function pageLoad() {
if (launch) {
$find("modalpopupextender client id need to pass here").show();
}
}

Client Side
============

OnClientClick="launchModal()"

serverside:=
============

Following code need to write in any button control click event

ClientScript.RegisterStartupScript(this.GetType(), "key", "launchModal();", true);

Using Javascript Read /Write Cookies

Following Code Will help For Reading And Writing cookie

sample code
============


How To Create
createCookie("slidingpane", "dock", 1);
How To Read
var pane = readCookie("slidingpane")



Ref Function

function createCookie(name, value, days) {
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
var expires = "; expires=" + date.toGMTString();
}
else var expires = "";
document.cookie = name + "=" + value + expires + "; path=/";
}

function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
}
return null;
}

function eraseCookie(name) {
createCookie(name, "", -1);
}