JavaScript

Validate radio button in datagrid, datalist, gridview on button

Posted on July 8, 2009. Filed under: Asp.net, Datalist, JavaScript, Repeater, gridview |

Here  ‘questionlist’ is the id of Datalist or datagrid or Gridview or repeater
u call this function on button events
<button onclick=”return isconfirm()” />
<script language=javascript>
function isconfirm()
{
var counter=0;
var obj=document.getElementById(“<%=questionlist.ClientID%>”).getElementsByTagName(“input”);
for(i=0;i<=obj.length-1;i++)
{
if(obj[i].type==”radio” && obj[i].checked==true)
{
counter++;
}
}
if(counter==0)
{ alert(‘Plz Select question Answer’);
return false
}
return true;
}
</script>

Read Full Post | Make a Comment ( None so far )

TextBox with numeric input only : textbox, only, numeric, input

Posted on December 24, 2008. Filed under: JavaScript |

function ISonlynumber(evt)
{
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 48 || charCode > 57))
return false;
return true;
}
<asp:TextBox ID=”txtmobileNO” Runat=”server” Width=”150″ MaxLength=”64″ onkeypress=”javascript:return ISonlynumber(event);”></asp:TextBox>

Read Full Post | Make a Comment ( None so far )

Set dropdownlist value from querystring in javascript

Posted on July 3, 2008. Filed under: JavaScript |

 <script language=javascript>
function SetSetectedVelue()
{
var id=’<%=Request.QueryString["cityid"] %>’;
if(id.length==0)
id=1;
var city=document.getElementById(‘<%=ddlcity.ClientID%>’);
for(var i=0;i<city.length;i++)
{
if(city.options[i].value==id)
city.selectedIndex=i;
}
}
</script>
<body onload=”SetSetectedVelue()”>
    <form id=”form1″ runat=”server”>
    <div>
<asp:DropDownList  id=”ddlcity” runat=server  >
<asp:ListItem value=”1″ >delhi</asp:ListItem>
<asp:ListItem value=”2″>mumbai</asp:ListItem>
<asp:ListItem value=”3″>channai</asp:ListItem>
<asp:ListItem value=”4″>kolkota</asp:ListItem>
</asp:DropDownList>
</div>
</form>
</body>

Read Full Post | Make a Comment ( 1 so far )

Display Rss data througth Javascript

Posted on July 1, 2008. Filed under: JavaScript |

function GetXmlHttpObject()
{
/*extern ActiveXObject, XMLHttpRequest */
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 // Internet Explorer
 try
 {
 xmlHttp=new ActiveXObject(“Msxml2.XMLHTTP”);
 }
 catch (e)
 {
 xmlHttp=new ActiveXObject(“Microsoft.XMLHTTP”);
 }
 }
return xmlHttp;
}
function displayRSS(url)
{var xmlhttp=GetXmlHttpObject();
if(xmlHttp==null)
{return;}
xmlHttp.open(“GET”,url,true);
xmlHttp.onreadystatechange=getRssFormat;
xmlHttp.send(null);
}
function getRssFormat()
{if(xmlHttp.readyState==4)
{if(xmlHttp.status != 200)
{
document.getElementById(“rss”).innerHTML= “<br><br><br>Sorry….<br><br><br><br>The Server did not return any results (Result code: 200)<br><br><br><br>Please try again<br><br>Sorry for the Inconvenience”;
}
else{
var items_count=3;
link=new Array(), title=new Array(), pubDate=new Array()
for(var i=0; i<items_count; i++) {
if(items.getElementsByTagName(‘item’)[i].getElementsByTagName(‘link’).length==1)
link[i]=items.getElementsByTagName(‘item’)[i].getElementsByTagName(‘link’)[0];
if(items.getElementsByTagName(‘item’)[i].getElementsByTagName(‘title’).length==1)
title[i]=items.getElementsByTagName(‘item’)[i].getElementsByTagName(‘title’)[0];
if(items.getElementsByTagName(‘item’)[i].getElementsByTagName(‘pubDate’).length==1)
pubDate[i]=getDateFormat(items.getElementsByTagName(‘item’)[i].getElementsByTagName(‘pubDate’)
[0].firstChild.nodeValue);
}
if(title.length==0)
return false;
var  ws=/\S/;
ul = document.createElement(“ul”);
var mydiv = document.getElementById(“rss”);
mydiv.appendChild(ul);
for(var [...]

Read Full Post | Make a Comment ( None so far )

Get web control value through javascript

Posted on June 28, 2008. Filed under: JavaScript |

<asp:TextBox id=”txtname” runat=server ></asp:TextBox>
<script>
function getvalue()
{
  var val=document.getElementById(‘<%=txtname.ClientID%>’).value;
  alert(val);
}

Read Full Post | Make a Comment ( 1 so far )

page bookmark in javascript

Posted on June 24, 2008. Filed under: JavaScript |

var urlAddress =window.location.href;
 var pageName = document.title;
  function addToFavorites()
  {
  if (window.external)
  {
  window.external.AddFavorite(urlAddress,pageName)
  }
  else
  {
  alert(“Sorry! Your browser doesn’t support this function.”);
  }
}

Read Full Post | Make a Comment ( None so far )

show hide layer on tab clicking

Posted on June 24, 2008. Filed under: JavaScript |

function showDiv(dvnm)
{
 document.getElementById(dvnm).style.display = ‘block’;
 document.getElementById(dvnm).style.visibility = ‘visible’;
}
function hideDiv(dvnm)
{
 document.getElementById(dvnm).style.display = ‘none’;
 document.getElementById(dvnm).style.visibility = ‘hidden’;
}
function showlayer(n)
{
 for(i=1;i<=2;i++)//number of layer u want to show
 {
  if(i==n)
  {
   showDiv(‘div’+ i);//dynamically call div id
   document.getElementById(‘tab’+i).style.backgroundColor=”#666666″;//dynamically show contant id
  }
  else
  {
   hideDiv(‘div’+ i); 
      document.getElementById(‘tab’+i).style.backgroundColor=”gray”;
  }
 }
}

Read Full Post | Make a Comment ( None so far )

show and hide content on next prev button

Posted on June 24, 2008. Filed under: JavaScript |

<table width=”99%” cellpadding=”3″ cellspacing=”1″ bgcolor=”#000000″>
                  <tr>
                    <td height=”20″ class=”photonamewhite”><div style=”float: right; width: 100px; position: relative; height: 25px;” class=smallphotoname align=”right”><a href=”#” class=”curhand” title=”Previous” onclick=”moveRight(‘div_hall’,90)”>«prev</a>   <a href=”#” title=”next” onclick=”moveLeft(‘div_hall’,90)”>next»</a></div></td>
                  </tr>
                  <tr>
                    <td  bgcolor=”#999999″ >
                   
                    <DIV style=”MARGIN-LEFT: 5px; OVERFLOW: hidden; background-color:#666666; WIDTH: 276px; POSITION: relative; HEIGHT: 184px”>
                        <DIV id=”div_hall” style=”LEFT: 0px; WIDTH:<%=(photo.Items.Count%6)==0?(photo.Items.Count/6)*270:((photo.Items.Count/6)+1)*270%>px; POSITION: absolute; TOP: 0px”>
                              
                               <asp:DataList ID=photo runat [...]

Read Full Post | Make a Comment ( None so far )

send data from html page to server pages

Posted on May 23, 2008. Filed under: JavaScript |

 

head>
<title>Untitled Page</title>
<script language=javascript>
function submitvalue()
{
var red=document.getElementById(‘rd’);
var val=“PH”;
if(rd[0].checked==true)
{val=“KH”;
}
window.location.href=“keywordsearch.aspx?kq=”+document.getElementById(‘txtsearch’).value+“&stype=”+val;
}
</script>
</head>
<body>
<input type=text name=”txtsearch” runat=server />
<input type=radio name=”rd” value=”KH” runat=server checked=checked/>
<input type=”radio” name=”rd” value=”PH” runat=server/>
<input type=”button” name=”btnsearch” value=”search” onclick=”submitvalue();”/>
</body>

Read Full Post | Make a Comment ( 2 so far )

Open .aspx page with parameter in popup window

Posted on May 16, 2008. Filed under: JavaScript |

<a href=”javascript:return false;” onclick=”javascript:window.open(’sendquery.aspx?rg=” + sd.REGID + “&comp=” + sd.COMPANYNAME + “&city=” + sd.CITYNAME + “‘,’smallwindowsms’,’toolbars=0,crollbars=0,width=600,
height=500,menubar=0,resizable=0′);return false;”>send query</a>

Read Full Post | Make a Comment ( None so far )

« Previous Entries

    About

    Hi,I am Suresh Sharma from Gorakhpur , UP, India.I have work on .net technology from 2 years. Key skills-Asp.net 2.0,3.5, Sql 2005,2000. Ajax.net 1.1,C#.net

    RSS

    Subscribe Via RSS

    • Subscribe with Bloglines
    • Add your feed to Newsburst from CNET News.com
    • Subscribe in Google Reader
    • Add to My Yahoo!
    • Subscribe in NewsGator Online
    • The latest comments to all posts in RSS
    • Subscribe in Rojo

    Meta

Liked it here?
Why not try sites on the blogroll...