Apr 8, 2010

Return identity column value

create table with identity column..
then in stored procedure create output parameter
at the end of stored procedure
assign output parameter to scope_identity()
ex:set @id=scope_identity()
return id

it returns the identity value.
in c#.net use the executescalar command object.

Apr 1, 2010

disable browswer back button

after logout disable browser back button


Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();

place the code in page load...

Mar 31, 2010

Show master page modalpoup extender in content page

show the master page modalpopup extender in content page..

First step to drag and drop modalpopup extender in master page. give the targetcontrol id and popupid and backgroundcssclass these are common properties,
but u have to show in content page u have to add another attribute 'BehaviourID'.
to give the name to behaviourid.

procedure to call in content page:

create an instance

modalpopupextender modalpopup=(modalpopupextender)page.master.FindControl("modalpopupextenderid");
modalpopup.show();

the above code mention in button click event.
after that in button source mention
"onclientclick="$find(BehaviourID);return false;"

it will works..

Jan 28, 2010

Limit the Displayed text in datalist or gridview

Solution:

Eval("description").substring(0,x)

here 'x' displayed limited characters.

Jan 6, 2010

Play swf files using javascript

javascript:
var str;

function display(name)
{
var elementId="charId";
str= swf object source here;

//First check for installed version of Flash Player - we need a minimum of 6
if((this.detectFlashVersion==1) && (this.installedVer.major < 6)){ if (this.autoInstallRedirect==1){ //If we can auto redirect to install the player? var installationConfirm = window.confirm("You need Adobe Flash Player 6 (or above) to view the charts. It is a free and lightweight installation from Adobe.com. Please click on Ok to install the same."); if (installationConfirm){ window.location = "http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash"; }else{ return false; } }else{ //Else, do not take an action. It means the developer has specified a message in the DIV (and probably a link). //So, expect the developers to provide a course of way to their end users. //window.alert("You need Adobe Flash Player 8 (or above) to view the charts. It is a free and lightweight installation from Adobe.com. "); return false; } }else{ //Render the chart var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId; n.innerHTML = str; //Added
compatibility
//Check if it's added in Mozilla embed array or if already exits
if(!document.embeds[this.getAttribute('id')] && !window[this.getAttribute('id')])
window[this.getAttribute('id')]=document.getElementById(this.getAttribute('id'));
//or else document.forms[formName/formIndex][chartId]
return true;
}
}

inhtml u call the method of javascript.

in body u can call: onload="display('charId')

a href="Javascript:display('Flash-Clock-103.swf')
a href="Javascript:display('OnlinePatentSearch.swf')

div id="charId" align="center"

show xml data in html using javascript

javascript:

var xmlDoc;
if (window.XMLHttpRequest)
{
xhttp=new XMLHttpRequest();
}
else // Internet Explorer 5/6
{
xhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xhttp.open("GET","cd_catalog",false);
xhttp.send("");
xmlDoc=xhttp.responseXML;

var x=xmlDoc.getElementsByTagName("CD");

function show(i)
{
artist=(x[i].getElementsByTagName("image")[0].childNodes[0].nodeValue);
//title=(x[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue);

txt="Artist: "+artist;
document.getElementById("show").innerHTML=txt;
}