Can't display results where the ending matches - c#

I'm making a rhyme dictionary, and I have a database table with 3 coloumns, the user will search the database and the search keywords will search database where the ending of the word matches with the word in textbox.
When I enter some keyword into textbox
I get ERROR: Incorrect syntax near the keyword 'LIKE'.
This is how my database looks like
Here is how my aspx looks like:
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Kafiye Dizini - Türkçe Kafiye Bulma Sözlüğü - Uyak Bulucu Sözlük - İstediğiniz harf ile biten kelimeleri bulan sözlük</title>
<meta name="description" content="İstediğiniz harfler ile biten kelimeleri bulmanızı sağlayan sözlük" />
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
<link href="style.css" rel="stylesheet" />
</head>
<body>
<form id="form1" runat="server">
<div>
<div class="top">
<div class="email">İletişim: fahrettinveysel#gmail.com</div>
</div>
<div class="leftcontainer">
</div>
<div class="middlecontainer">
<div class="title">Kafiye Dizini</div>
<div class="subtitle">İstediğiniz harf veya hece ile biten kelimeleri bulmanızı sağlayan sözlük</div>
<div class="searchcontainer">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
</div>
<div class="resultboxcontainer">
<div id="resultbox1" runat="server"></div>
<div id="resultbox2" runat="server"></div>
<div id="resultbox3" runat="server"></div>
</div>
<div class="idefix"></div>
</div>
<div class="rightcontainer">
<div class="ornekarama">
<div class="ornekaramabaslik">Örnek Arama</div>
<input type="text" class="ornekaramatextbox" value="rop" disabled="disabled" />
<div class="ornekaramasonuclar">filantrop<br />gardırop<br />hipermetrop<br />mikrop<br />mizantrop</div>
</div>
</div>
</div>
</form>
</body>
</html>
and this is my aspx.cs
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
SqlConnection cnn = new SqlConnection("Initial Catalog=kafiyedizini;Data Source=localhost;Integrated Security=SSPI;");
protected void Button1_Click(object sender, EventArgs e)
{
if (TextBox1.Text != "")
{
cnn.Open();
SqlCommand cmd = new SqlCommand("SELECT kelime1,kelime2,kelime3 FROM kelimeler LIKE #arama", cnn);
cmd.Parameters.AddWithValue("#arama", "%" + TextBox1.Text);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
while (dr.Read())
{
resultbox1.InnerHtml += dr.GetString(0);
resultbox2.InnerHtml += dr.GetString(1);
resultbox3.InnerHtml += dr.GetString(2);
}
}
cnn.Close();
}
else
{
resultbox1.InnerHtml += "please enter data";
}
}
}

The initial sql statement in your question should look like this
SELECT kelime1,kelime2,kelime3 FROM kelimeler where kelime1 LIKE #arama OR kelime2 LIKE #arama or kelime3 like #arama
You missed the where and the fields you want to use in your like statement.
to have each result in a separate 'box' you better investigate how a GridView works or a DataRepeater.
Closest in your initial code what could work, including support for handling null/emtpy values for one the fields returned, nicely filling the 3 resultboxes:
var f1 = dr.GetString(0);
var f2 = dr.GetString(1);
var f3 = dr.GetString(2);
if (!String.IsNullOrEmpty(f1))
resultbox1.InnerHtml += String.Format("<div>{0}</div>",f1);
if (!String.IsNullOrEmpty(f2))
resultbox2.InnerHtml += String.Format("<div>{0}</div>",f2);
if (!String.IsNullOrEmpty(f3))
resultbox1.InnerHtml += String.Format("<div>{0}</div>",f3);

You are missing WHERE part of the SQL query
Example:
SELECT * FROM test WHERE test.Id LIKE '%asd%'
I also think, dr.Read() executes PER ROW.
Hope this helps

Related

i am trying to run a asp.net method with an html submit button but method would not run?

I want the method submit_click to be activated when the submit button on the HTML part is pressed
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Debug="true" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server" method="post" onsubmit="Submit_Click">
mail<br />
<asp:TextBox ID="mail" runat="server" Style="margin-left: 0px">mail</asp:TextBox>
<br />
name<br />
<asp:TextBox ID="name" runat="server" Width="117px">name</asp:TextBox>
<br />
last
<br />
<asp:TextBox ID="last" runat="server">name</asp:TextBox>
<p>
pass
</p>
<p>
<asp:TextBox ID="password" runat="server">password</asp:TextBox>
</p>
id <p>
<asp:TextBox ID="id1" runat="server">id</asp:TextBox>
</p>
<input id="Submit" type="submit" value="submit" onserverclick="Submit_Click()" />
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Submit_Click(object sender, EventArgs e)
{
OleDbConnection conn = new OleDbConnection(#"Provider=Microsoft.ACE.OLEDB.12.0; Data source = " + Server.MapPath("") + "\\Database.accdb");
conn.Open();
string com = "INSERT into myusers (myid,myname,mymail,mypass,mylast) VALUES ('" + id1.Text + "," +name.Text + "," + mail.Text + "," +password.Text + "," + last.Text + "')";
OleDbCommand comm = new OleDbCommand(com, conn);
comm.ExecuteNonQuery();
conn.Close();
}
}
Actually why you're doing this , that i don't know because Asp Button will also converted like below on browser side, Still if you want to use it put runat="server", try below code.
<input id="Submit" runat="server" type="submit" value="submit" onserverclick="Submit_ServerClick" />
You are missing 'runat="server"'. Include it in the submit control.

WebForms keeps showing Event validation error on post

When I try to submit information from client to server, I receive Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/>. I've tried most of the suggestions in the answers and they don't seem to be helping.
At the top of the .aspx page in question, adding EnableEventValidation="false" does solve the issue. However, I would like to this to remain as set to true.
I've also added (!Page.IsPostBack) in the code behind and this is still causing issues.
Could it be the jQuery timpicker that's causing the issue by inputting values based on what the user selects?
Code behind .cs
public partial class _Default : Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
var DbHelper = new DbHelper();
listOfUsers.DataSource = DbHelper.UserList();
listOfUsers.DataBind();
}
else
{
string test = listOfUsers.SelectedValue;
string time = timePicker.Text;
string reason = ReasonForRemoval.Text;
}
}
}
.aspx file
<%# Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="xxxMyProjectNamexxx" EnableEventValidation="true"%>
<%--<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>--%>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src='https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js' type='text/javascript'></script>
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<script type="text/javascript" src="/Scripts/jquery-ui-timepicker-addon.js"></script>
<link rel="stylesheet" href="/Styles/jquery-ui-timepicker-addon.css">
<script type="text/javascript">
jQuery(document).ready(function ($) {
$('[id*=timePicker]').timepicker({
timeFormat: "hh:mm:ss"
});
});
</script>
<head>
<h2>
My App
</h2>
<p>
Enter relevant info
</p>
</head>
<body>
<form method="post">
<div>
<label for="UserName">User Name:</label>
<asp:DropDownList ID="listOfUsers" runat="server"></asp:DropDownList>
</div>
<br/><br/>
<table>
<tr>
<th>
<div>
<label for="Time">Time:</label>
<asp:TextBox ID="timePicker" runat="server"></asp:TextBox>
</div>
</th>
</tr>
</table>
<br/><br/>
<div>
<label for="Reason">Reaso:</label>
<br/>
<asp:TextBox ID="ReasonForRemoval" runat="server" TextMode="MultiLine" Rows="5" Width="400px" style="resize:none"></asp:TextBox>
</div>
<br/><br/>
<div>
<label> </label>
<input type="submit" value="Submit" class="submit" />
</div>
</form>
</body>
</asp:Content>
DbHelper.cs used to generate list
public class DbHelper
{
private EntityConnection entCon;
public DbHelper()
{
entCon = new EntityConnection(ConfigurationManager.ConnectionStrings["myConnString"].ConnectionString);
}
public List<string> UserList()
{
List<string> userList = new List<string>();
using(SqlConnection conn = (SqlConnection)entCon.StoreConnection)
using (SqlCommand cmd = new SqlCommand())
{
conn.Open();
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "SELECT * FROM [MyDatabase].[dbo].[users]";
using (SqlDataReader objReader = cmd.ExecuteReader())
{
if (objReader.HasRows)
{
while (objReader.Read())
{
userList.Add(Convert.ToString(objReader[0]));
}
}
}
}
return userList;
}
}
}

While inserting record into SQL Server database form asp.net web form its inserting twice

I am inserting values into a web form and submitting the web form. The record gets inserted twice in my SQL Server 2014 database. My web form code and code behind logic are below.
I don't know why the record is being inserted twice into the database.
Web form code:
<%# Page Language="C#" AutoEventWireup="true" CodeFile="register.aspx.cs" Inherits="register" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Social Login Form Flat Responsive widget Template :: w3layouts</title>
</head>
<body>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="Social Login Form Widget Responsive, Login form web template,Flat Pricing tables,Flat Drop downs Sign up Web Templates, Flat Web Templates, Login signup Responsive web template, Smartphone Compatible web template, free webdesigns for Nokia, Samsung, LG, SonyEricsson, Motorola web design" />
<script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
<!-- font files -->
<link href='/../fonts.googleapis.com/css?family=Muli:400,300' rel='stylesheet' type='text/css'>
<link href='/../fonts.googleapis.com/css?family=Nunito:400,300,700' rel='stylesheet' type='text/css'>
<!-- /font files -->
<!-- css files -->
<link href="login.css" rel='stylesheet' type='text/css' media="all" />
<!-- /css files -->
</head>
<body>
<h1>Social Login Form</h1>
<div class="log">
<div class="social w3ls">
<li class="f"><img src="images/fb.png" alt=""></li>
<li class="t"><img src="images/twt.png" alt=""></li>
<li class="p"><img src="images/pin.png" alt=""></li>
<li class="i"><img src="images/ins.png" alt=""></li>
<div class="clear"></div>
</div>
<div class="content2 w3agile">
<h2>Sign Up</h2>
<form ID="form" runat="server" method="post">
<asp:TextBox ID="name" runat="server" placeholder="Name Surname" pattern="[A-Za-z]+\s[A-Za-z]+" title="Firstname Surname" required></asp:TextBox>
<asp:TextBox ID="username" runat="server" placeholder="Username" title="Username" required></asp:TextBox>
<asp:TextBox ID="phoneno" runat="server" placeholder="Phone Number" pattern="[7-9]{1}[0-9]{9}" required title="Phone number starting with 7-9 and remaing 9 digit with 0-9"></asp:TextBox>
<asp:TextBox ID="email" type="email" runat="server" placeholder="Email Address" required ></asp:TextBox>
<asp:TextBox ID="password" runat="server" type="password" placeholder="Password" required title="Any number of characters or special characters"></asp:TextBox>
<input id="confirm_password" placeholder="Confirm Password" runat="server" type="password" required title="Any number of characters or special characters"></input>
<script type="text/javascript">
var password = document.getElementById("password")
, confirm_password = document.getElementById("confirm_password");
function validatePassword() {
if (password.value != confirm_password.value) {
confirm_password.setCustomValidity("Passwords Don't Match");
} else {
confirm_password.setCustomValidity('');
}
}
password.onchange = validatePassword;
confirm_password.onkeyup = validatePassword;
</script>
<asp:Button ID="Button1" runat="server" Text="Sign up" class="register" OnClick="btn_Click" />
<h3>Already have an account? Sign In</h3>
</div>
</div>
<div class="footer">
<p>© 2016 Social Login Form. All Rights Reserved | Design by w3layouts</p>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
</html>
Code behind:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
public partial class register : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btn_Click(object sender, EventArgs e)
{
int userId = 0;
SqlConnection con = new SqlConnection(#"Data Source=RISHIK\SQLEXPRESS;Initial Catalog=Register;Integrated Security=True");
String query = "Insert into Table_2 values('"+name.Text+"','"+username.Text+"','"+phoneno.Text+"','"+email.Text+"','"+password.Text+"')";
con.Open();
SqlCommand cmd = new SqlCommand(query, con);
userId = Convert.ToInt32(cmd.ExecuteScalar());
cmd.ExecuteNonQuery();
//Label1.Text = "Hjg";
con.Close();
}
}
this line
userId = Convert.ToInt32(cmd.ExecuteScalar());
is not doing what you think. it will execute the insert statement and then return a scalar value.
then your next line:
cmd.ExecuteNonQuery();
will insert the record again
this is what Blorgbeard is trying to tell you.
that is why it is inserting twice.
also - you should consider parameterizing that query. taking the value of your user input and creating your query with those values without checking them is just begging for a sql injection attack
Use parameterised query , something like....
int userId = 0;
SqlConnection con = new SqlConnection(#"Data Source=RISHIK\SQLEXPRESS;Initial Catalog=Register;Integrated Security=True");
SqlCommand cmd = new SqlCommand("Insert into Table_2 values(#Name, #UserName, #Phone, #Email, #Password);
SELECT CAST(scope_identity() AS int)", con);
cmd.Parameters.AddWithValue("#Name", name.Text);
cmd.Parameters.AddWithValue("#UserName", username.Text);
cmd.Parameters.AddWithValue("#Phone", phoneno.Text);
cmd.Parameters.AddWithValue("#Email", email.Text);
cmd.Parameters.AddWithValue("#Password", password.Text);
con.Open();
userId = (Int)cmd.ExecuteScalar();

html master page with data base sql server

plss help i have this problem:
Invalid postback or callback argument. Event validation is enabled using in configuration or <%# Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.
this is the master page code:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<link rel="shortcut icon" type="icon/x-icon" href="Main Images/favicon.ico" />
<link rel="stylesheet" type="text/css" href="MyStyle.css" />
<link href="style.css" rel="stylesheet" />
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body style="background-image: url('Main Images/background.jpg');">
<form id="form1" runat="server">
<div dir="rtl" style="background-color:#242020">
<audio src="songs/Jurassic Park Theme Song - Jurassic Park Theme Song.mp3" autoplay="" controls=""></audio><br /><br />
</div>
<div class="top">
<center> <img src="Main Images/logo.png" /></center>
<div>
<form name="login">
<span style="margin-top:25px;color:goldenrod;margin-left:3%;">Username<span style="margin-left:7px"><asp:TextBox type="text" id="userid" name="userid" style="color:fuchsia" placeholder="User Name" class="gg" runat="server"></asp:TextBox></span></span><br /><br />
<span style="margin-top:25px;color:goldenrod;margin-left:3%">Password<span style="margin-left:7px"><asp:TextBox class="gg" type="password" id="pswrd" name="pswrd" style="color:goldenrod" placeholder="Password" runat="server"></asp:TextBox><br /></span></span><p runat="server" id="ans" style="color:red"></p>
<span style="margin-left:4%"><asp:Button ID="Button1" onclick="Check_Click" class="login" runat="server" Text="Login" />
<input type="reset" class="cencel" value="Cancel"/></span><br /><br /><span style="margin-left:4.7%"><a class="button" href="Had Sign Up.aspx">sign up to HaD</a></span>
</form>
<script type="text/javascript">
function check(form) {
if(form.userid.value == "Oz Cohen" && form.pswrd.value == "guzguz8") {
window.open('HaDMan.aspx');
}
else {
if (form.userid.value != "Oz Cohen" && form.pswrd.value!= "guzguz8") { document.getElementById("ans").innerHTML = ("Eror Username and Password") }
if (form.userid.value == "Oz Cohen" && form.pswrd.value != "guzguz8") { document.getElementById("ans").innerHTML = ("Eror Password") }
if (form.userid.value != "Oz Cohen" && form.pswrd.value == "guzguz8") { document.getElementById("ans").innerHTML = ("Eror Username") }
}
}
</script>
</div>
<center>
<asp:Table ID="Table2" runat="server" style="margin-top:7px">
<asp:TableRow>
<asp:TableCell> <nav class="menu">
<ul class="clearfix">
<li>
<img style="margin-top:-20px"width="60" src="Main Images/lines.png" />
<ul class="sub-menu">
<li>My site page</li>
<li><a title="Got lost? Click here for the site map..." href="sitemap.aspx">Map of the site</a></li>
<li>Dinosuars Movies</li>
<li>Add new Dinosuars species</li>
<li>Had Site</li>
</ul>
</li>
</ul>
</nav></asp:TableCell>
<asp:TableCell>
<nav class="menu" >
<ul>
<li><span class="mainmenu">Home page</span></li>
</ul>
</nav>
</asp:TableCell>
<asp:TableCell>
<nav class="menu" >
<ul>
<li><span class="mainmenu">Carnivores</span></li>
</ul>
</nav>
</asp:TableCell>
<asp:TableCell>
<nav class="menu" >
<ul>
<li><span class="mainmenu">Vegetarian</span></li>
</ul>
</nav>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</div>
<div>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
this is the c# code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
public partial class DinoMenu : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Check_Click(object sender, EventArgs e)
{
SqlConnection c;
string str = "Data Source =(LocalDB)\\MSSQLLocalDB;";
str += "AttachDbFilename=|DataDirectory|\\DinoData.mdf;";
str += "Integrated Security= True";
c = new SqlConnection(str);
SqlCommand Cmd = new SqlCommand("SELECT COUNT(*) FROM [User] WHERE Pasword LIKE #Pasword AND Username LIKE #username;", c);
Cmd.Parameters.AddWithValue("#Pasword", pswrd.Text);
Cmd.Parameters.AddWithValue("#username", userid.Text);
c.Open();
int Userexist = (int)Cmd.ExecuteScalar();
c.Close();
if (Userexist > 0)
{
Response.Redirect("HaD.aspx", true);
}
else
{
ans.InnerText = "Eror Username and Password";
}
}
}
The problem you are having is because of this line:
<form name="login">
Delete this line and you will be ok.
If you have to gather the elements of your login form together, change it to a div instead
Explanation
HTML files cannot contain nested forms.
Every .aspx/.master file is already a form (That's the origin for the name Web Forms).
When you put a <form> inside one of these files you actually put your new form inside .NET's auto-created form

Can';t work using html textbox to login

Because I am using html buttons and textbox to login, I must do the code behind in the javascript in the source code in order to do the code behind. Whether I login using the correct username and password which is Admin and 123 and click the login button, or I type in nothing and click the login button, it always redirects me to ResultDetails.aspx. That means login fail. Login will pass if it redirect me to Search.aspx. What's Wrong? Even if I change .Value to .Text, it is still the same effect
MY SOURCE CODE
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Login.aspx.cs" Inherits="Login" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
</style>
<link rel="stylesheet" type="text/css" href="stylesheets/loginstyle.css" />
<script language="javascript" type="text/javascript">
// <![CDATA[
function Button1_onclick() {
if (txtUserName.Value == "Admin" && txtPassword.Value == "123") {
//Login as Hardcoded User
//Do your stuff
window.location.assign("Search.aspx")
}
else {
window.location.assign("ResultDetails.aspx")
}
}
// ]]>
</script>
</head>
<body>
<div id="wrapper">
<form name="login-form" class="login-form" action="" method="post">
<div class="header">
<h1>Login Form</h1>
<span>Fill out the form below to login to my super awesome imaginary control panel.</span>
</div>
<div class="content">
<input name="username" type="text" class="input username" placeholder="Username" runat="server" id="txtUserName" />
<div class="user-icon"></div>
<input name="password" type="password" class="input password" placeholder="Password" runat="server" id="txtPassword" />
<div class="pass-icon"></div>
</div>
<div class="footer">
<input type="button" name="submit" value="Login" class="button" runat="server" id="Button1" önserverclick="Button1_Click" onclick="return Button1_onclick()" />
</div>
</form>
</div>
<div class="gradient"></div>
</body>
</html>
MY CODE BEHIND CODE
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
You are not using asp.net server controls to access values like
txtUserName.Value
Rather, you are using Javascript on HTML Controls. So, your syntax should be like:
if (document.getElementById("txtUserName").value == "Admin" && document.getElementById("txtPassword").value == "123")
You need to access the fields properly
e.g.
if (document.getElementById('txtUserName').value == "Admin" && document.getElementById('txtPassword').value == "123")
If you are using Jquery lib in your code
You can also do
if($.("#txtUserName").val()=="Admin" && $.("#txtPasword").val()=="123")
You can try below code which fetches the value from text boxes using the id in JavaScript.
function Button1_onclick() {
if (document.getElementById('txtUserName').value == "Admin" && document.getElementById('txtPassword').value == "123") {
//Login as Hardcoded User
//Do your stuff
window.location.assign("Search.aspx")
}
else {
window.location.assign("ResultDetails.aspx")
}
}
if (document.getElementById("txtUserName").value == "Admin"
&& document.getElementById("txtPassword").value == "123")

Categories

Resources