==>> Create a website in add new page and paste the Code:--
1. ASPX PAGE CODE:-
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Asp .NET control Enable or Disable using javascript</title>
<script language="javascript" type="text/javascript">
function ButtonStatus() {
var txtvalue = document.getElementById('txtVal');
if (txtvalue.value == "enable")
document.getElementById('btnEnable').disabled = false;
else
document.getElementById('btnEnable').disabled = true;
}
</script>
</head>
<body>
<div>
<input type="text" id="txtVal" onkeyup="ButtonStatus(this,'btnEnable')" />
<input type="button" id="btnEnable" value="Button" disabled="disabled" />
</div>
</body>
</html>
Hope this will help you.....
'C# .NET ASP .NET,Grid View,DropDownList,AJAX,JavaScript,JQuery,asp.net articles,C#.NET Articles,ASP,ASP.NET,C#,VB,CSharp,C Sharp,dotnet,subhash jakhar,GridView,DropDownList,Visual Studio,ajax,Java Script,JQuery,XML,Crystal Reports,SSIS,SSRS,DetailsView,winforms,windows forms,windows application,code samples,.net code examples'
Friday, March 29, 2013
Onclick select all Text in Textbox using Javascript in Asp .NET
==>> Create a website in add new page and paste the Code:--
1. ASPX PAGE CODE:-
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Onclick select all Text in Textbox using Javascript in Asp .NET</title>
<script type="text/javascript">
function SelectAll(id) {
document.getElementById(id).focus();
document.getElementById(id).select();
}
</script>
</head>
<body>
<div>
Enter Strengths :<br/>
<input type="text" id="TxtStrengths" onclick="SelectAll('TxtStrengths');" style="width:200px" value = "I am very confident and a good player of cricket" /><br />
Hobbies :<br/>
<textarea rows="5" cols="23" id="TxtHobbies" onclick="SelectAll('TxtHobbies');" style="width:200px" I like playing cricket. </textarea>
</div>
</body>
</html>
Hope this will help you....
1. ASPX PAGE CODE:-
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Onclick select all Text in Textbox using Javascript in Asp .NET</title>
<script type="text/javascript">
function SelectAll(id) {
document.getElementById(id).focus();
document.getElementById(id).select();
}
</script>
</head>
<body>
<div>
Enter Strengths :<br/>
<input type="text" id="TxtStrengths" onclick="SelectAll('TxtStrengths');" style="width:200px" value = "I am very confident and a good player of cricket" /><br />
Hobbies :<br/>
<textarea rows="5" cols="23" id="TxtHobbies" onclick="SelectAll('TxtHobbies');" style="width:200px" I like playing cricket. </textarea>
</div>
</body>
</html>
Hope this will help you....
Check Empty Value or Null Value using JQuery in ASP .NET
==>> Create a website in add new page and paste the Code:--
1. ASPX PAGE CODE:-
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Empty Value or Null Value using JQuery in ASP .NET</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
$(function () {
$('#btnClick').click(function () {
var str = $('#txtfield');
if (str.val() != null && str.val() != '') {
alert('you entered String ' + str.val())
}
else {
alert('Please enter text')
}
})
});
</script>
</head>
<body>
<div>
Enter Text: <input type="text" id="txtfield" />
<input type="button" id="btnClick" value="Click" />
</div>
</body>
</html>
1. ASPX PAGE CODE:-
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Empty Value or Null Value using JQuery in ASP .NET</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
$(function () {
$('#btnClick').click(function () {
var str = $('#txtfield');
if (str.val() != null && str.val() != '') {
alert('you entered String ' + str.val())
}
else {
alert('Please enter text')
}
})
});
</script>
</head>
<body>
<div>
Enter Text: <input type="text" id="txtfield" />
<input type="button" id="btnClick" value="Click" />
</div>
</body>
</html>
Wednesday, March 20, 2013
Change Row Color on Mouse Over and Highlight gridview rows on mouseover using JavaScript in C# Asp .Net
==>> Create a table in SQL Employee and create a website in add new page and paste the Code:--
1. ASPX PAGE CODE:-
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Asp .Net Gridview row color change on Mouse Over </title>
<script type="text/javascript">
var originalgridcolor;
function FnColorChangeMouseOver(element) {
originalgridcolor = element.style.backgroundColor;
element.style.backgroundColor = '#94a8ff';
element.style.cursor = 'pointer';
element.style.textDecoration = 'underline';
}
function FnColorChangeMouseOut(element) {
element.style.backgroundColor = originalgridcolor;
element.style.textDecoration = 'none';
}
</script>
</head>
<body>
<form id="FrmMouseOver" runat="server">
<div>
<asp:GridView runat="server" ID="EmpTestGrid" AutoGenerateColumns="false"
HeaderStyle-BackColor="#EB94FF" HeaderStyle-ForeColor="White"
onrowdatabound="EmpTestGrid_RowDataBound">
<Columns>
<asp:BoundField DataField="EmpName" HeaderText="Name" />
<asp:BoundField DataField="FName" HeaderText="Father Name" />
<asp:BoundField DataField="EmpEmail" HeaderText="Email" />
</Columns>
</asp:GridView>
</div>
</form>
</body>
</html>
2. ASPX.CS PAGE CODE:-
using System;
using System.Data;
using System.Data.SqlClient;
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
BindGrid();
}
}
protected void EmpTestGrid_RowDataBound(object sender, GridViewRowEventArgs e)
{
if(e.Row.RowType== DataControlRowType.DataRow)
{
e.Row.Attributes["onmouseover"] = "javascript:FnColorChangeMouseOver(this)";
e.Row.Attributes["onmouseout"] = "javascript:FnColorChangeMouseOut(this)";
}
}
protected void BindGrid()
{
SqlConnection con =
new SqlConnection("Data Source=Subhash;Integrated Security=true;Initial Catalog=EmployeeTest");
con.Open();
SqlCommand sqlcmd = new SqlCommand("select * from Employee", con);
sqlcmd.ExecuteNonQuery();
SqlDataAdapter sqlda = new SqlDataAdapter(sqlcmd);
DataSet ds = new DataSet();
sqlda.Fill(ds);
EmpTestGrid.DataSource = ds;
EmpTestGrid.DataBind();
con.Close();
}
Hope this help you
1. ASPX PAGE CODE:-
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Asp .Net Gridview row color change on Mouse Over </title>
<script type="text/javascript">
var originalgridcolor;
function FnColorChangeMouseOver(element) {
originalgridcolor = element.style.backgroundColor;
element.style.backgroundColor = '#94a8ff';
element.style.cursor = 'pointer';
element.style.textDecoration = 'underline';
}
function FnColorChangeMouseOut(element) {
element.style.backgroundColor = originalgridcolor;
element.style.textDecoration = 'none';
}
</script>
</head>
<body>
<form id="FrmMouseOver" runat="server">
<div>
<asp:GridView runat="server" ID="EmpTestGrid" AutoGenerateColumns="false"
HeaderStyle-BackColor="#EB94FF" HeaderStyle-ForeColor="White"
onrowdatabound="EmpTestGrid_RowDataBound">
<Columns>
<asp:BoundField DataField="EmpName" HeaderText="Name" />
<asp:BoundField DataField="FName" HeaderText="Father Name" />
<asp:BoundField DataField="EmpEmail" HeaderText="Email" />
</Columns>
</asp:GridView>
</div>
</form>
</body>
</html>
2. ASPX.CS PAGE CODE:-
using System;
using System.Data;
using System.Data.SqlClient;
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
BindGrid();
}
}
protected void EmpTestGrid_RowDataBound(object sender, GridViewRowEventArgs e)
{
if(e.Row.RowType== DataControlRowType.DataRow)
{
e.Row.Attributes["onmouseover"] = "javascript:FnColorChangeMouseOver(this)";
e.Row.Attributes["onmouseout"] = "javascript:FnColorChangeMouseOut(this)";
}
}
protected void BindGrid()
{
SqlConnection con =
new SqlConnection("Data Source=Subhash;Integrated Security=true;Initial Catalog=EmployeeTest");
con.Open();
SqlCommand sqlcmd = new SqlCommand("select * from Employee", con);
sqlcmd.ExecuteNonQuery();
SqlDataAdapter sqlda = new SqlDataAdapter(sqlcmd);
DataSet ds = new DataSet();
sqlda.Fill(ds);
EmpTestGrid.DataSource = ds;
EmpTestGrid.DataBind();
con.Close();
}
Hope this help you
Print Grid View Data Using Java Script C# Asp .Net
==>> Create a table in SQL Employee and create a website in add new page and paste the Code:--
1. ASPX PAGE CODE:-
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Print Gridview Data</title>
<script type="text/javascript">
function Print() {
var PrintGrid = document.getElementById('<%=EmpGrid.ClientID %>');
PrintGrid.border = 0;
var PrintGridWindow = window.open('', 'PrintGridViewData', 'left=100,top=100,width=1000,height=1000,tollbar=0,scrollbars=1,status=0,resizable=1');
PrintGridWindow.document.write(PrintGrid.outerHTML);
PrintGridWindow.document.close();
PrintGridWindow.focus();
PrintGridWindow.print();
PrintGridWindow.close();
}
</script>
</head>
<body>
<form id="FmGridPrint" runat="server">
<div>
<b>Print Gridview</b><br /><br />
<asp:GridView ID="EmpGrid" runat="server" >
</asp:GridView>
<input type="button" id="btnPrint" value="Print" onclick="Print()" />
</div>
</form>
</body>
</html>
2. ASPX.CS PAGE CODE:-
using System;
using System.Data;
using System.Data.SqlClient;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindGrid();
}
}
protected void BindGrid()
{
using (SqlConnection con = new SqlConnection("Initial Catalog=EmployeeTest;Data Source=SUBHASH;Integrated Security=true"))
{
con.Open();
SqlCommand cmd = new SqlCommand("Select * from Employee", con);
SqlDataReader dr = cmd.ExecuteReader();
EmpGrid.DataSource = dr;
EmpGrid.DataBind();
con.Close();
}
}
1. ASPX PAGE CODE:-
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Print Gridview Data</title>
<script type="text/javascript">
function Print() {
var PrintGrid = document.getElementById('<%=EmpGrid.ClientID %>');
PrintGrid.border = 0;
var PrintGridWindow = window.open('', 'PrintGridViewData', 'left=100,top=100,width=1000,height=1000,tollbar=0,scrollbars=1,status=0,resizable=1');
PrintGridWindow.document.write(PrintGrid.outerHTML);
PrintGridWindow.document.close();
PrintGridWindow.focus();
PrintGridWindow.print();
PrintGridWindow.close();
}
</script>
</head>
<body>
<form id="FmGridPrint" runat="server">
<div>
<b>Print Gridview</b><br /><br />
<asp:GridView ID="EmpGrid" runat="server" >
</asp:GridView>
<input type="button" id="btnPrint" value="Print" onclick="Print()" />
</div>
</form>
</body>
</html>
2. ASPX.CS PAGE CODE:-
using System;
using System.Data;
using System.Data.SqlClient;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindGrid();
}
}
protected void BindGrid()
{
using (SqlConnection con = new SqlConnection("Initial Catalog=EmployeeTest;Data Source=SUBHASH;Integrated Security=true"))
{
con.Open();
SqlCommand cmd = new SqlCommand("Select * from Employee", con);
SqlDataReader dr = cmd.ExecuteReader();
EmpGrid.DataSource = dr;
EmpGrid.DataBind();
con.Close();
}
}
Grid View column convert in hyperlink field in C# Asp .NET
==>>Some time we need convert Grid View column in hyperlink field So I am posting TWO way using this You can convert Grid View Field in hyperlink fields and Take database field according to field Bind in Grid View:--
1.
<asp:GridView runat="server" ID="mydridtest" AutoGenerateColumns="false"
DataKeyNames="EmpId">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:HyperLink ID="HyperLinkEmp" Text='<%# Bind("EmpName") %>' NavigateUrl='<%# Bind("EmpName", "~/image/{0}") %>' runat="server"/>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="FName" HeaderText="FName" />
<asp:BoundField DataField="Address" HeaderText="Address" />
</Columns>
</asp:GridView>
1.
<asp:GridView runat="server" ID="mydridtest" AutoGenerateColumns="false"
DataKeyNames="EmpId">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:HyperLink ID="HyperLinkEmp" Text='<%# Bind("EmpName") %>' NavigateUrl='<%# Bind("EmpName", "~/image/{0}") %>' runat="server"/>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="FName" HeaderText="FName" />
<asp:BoundField DataField="Address" HeaderText="Address" />
</Columns>
</asp:GridView>
Subscribe to:
Posts (Atom)