how to apply javascript to asp.net control ?
expalin with examplee..
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Satyapriya NayakRank #47 · 31.5K reputationPosted Mar 12, 2013, 8:37 PM EDT
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
namespace Login_related_details
{
public partial class Login : System.Web.UI.Page
{
string strConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlCommand com;
SqlDataAdapter sqlda;
string str;
DataTable dt;
int RowCount;
protected void btn_login_Click(object sender, EventArgs e)
{
string UserName = TextBox_user_name.Text.Trim();
string Password = TextBox_password.Text.Trim();
SqlConnection con = new SqlConnection(strConnString);
con.Open();
str = "Select * from Login";
com = new SqlCommand(str);
sqlda = new SqlDataAdapter(com.CommandText, con);
dt = new DataTable();
sqlda.Fill(dt);
RowCount = dt.Rows.Count;
for (int i = 0; i < RowCount; i++)
{
UserName = dt.Rows[i]["UserName"].ToString();
Password = dt.Rows[i]["Password"].ToString();
if (UserName == TextBox_user_name.Text && Password == TextBox_password.Text)
{
Session["UserName"] = UserName;
Response.Redirect("Details.aspx");
}
else
{
lb1.Text = "Invalid User Name or Password! Please try again!";
}
}
}
}
}
Vishal GilbileRank #268 · 9.4K reputationPosted Mar 12, 2013, 8:51 PM EDT
Kindly go through the following links.
http://www.c-sharpcorner.com/UploadFile/17e8f6/controlling-button-execution-through-javascript-function/
http://www.c-sharpcorner.com/UploadFile/17e8f6/repeater-control-in-Asp-Net/
http://www.c-sharpcorner.com/uploadfile/17e8f6/how-to-getset-values-of-controls-in-Asp-Net-using-javascript/
http://www.c-sharpcorner.com/uploadfile/17e8f6/populate-a-dropdownlist-control-using-javascript-in-Asp-Net/
http://www.c-sharpcorner.com/uploadfile/17e8f6/how-to-create-a-calendar-control-in-Asp-Net/
Hope that solves your problem. Kindly mark the answer as accepted if it helps you.
With Regards,
Vishal Gilbile.
Sreejesh SPRank #1,975 · 740 reputationPosted Mar 12, 2013, 8:56 PM EDT
I will explain a validation for using javascript
This script use to allow alphabets in textbox,not allow numeric charecter in text box,please
try this code and again implement another j script code by using this method
Thanks
sreejesh