SignUp data not showing up in database in ASP.NET project - c#

I am trying to make a signup page in my asp.net project where I am using SQL Server for my project. But the problem is that the data is not going to the database on clicking signup button.
Here is my code which I have tried for usersignup.aspx, usersignup.aspx.cs, web.config.
usersignup.aspx
<%# Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="usersignup.aspx.cs" Inherits="BookManagement.usersignup" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div class="container">
<div class="row">
<div class="col-md-8 mx-auto">
<div class="card" style="border-radius:30px;background: #e9efef;">
<div class="card-body">
<div class="row">
<div class="col">
<center>
<img src="imgs/generaluser.png" style="width:90px;height:90px;text-align:center;vertical-align:middle;"/>
</center>
</div>
</div>
<div class="row">
<h4 style="text-align:center;">User SignUp</h4>
</div>
<div class="row">
<div class="col">
<hr>
</div>
</div>
<div class="row">
<div class="col-md-6">
<label>Full Name : </label>
<div class="form-group">
<asp:TextBox CssClass="form-control" ID="TextBox1" runat="server" Placeholder="Full Name"></asp:TextBox>
</div>
</div>
<div class="col-md-6">
<label>Date Of Birth : </label>
<div class="form-group">
<asp:TextBox CssClass="form-control" ID="TextBox2" runat="server" Placeholder="Date" TextMode="Date"></asp:TextBox>
</div>
</div>
</div>
<br>
<div class="row">
<div class="col-md-6">
<label>Contact NO : </label>
<div class="form-group">
<asp:TextBox CssClass="form-control" ID="TextBox3" runat="server" Placeholder="Contact No" TextMode="Number"></asp:TextBox>
</div>
</div>
<div class="col-md-6">
<label>Email : </label>
<div class="form-group">
<asp:TextBox CssClass="form-control" ID="TextBox4" runat="server" Placeholder="Email" TextMode="Email"></asp:TextBox>
</div>
</div>
</div>
<br>
<div class="row">
<div class="col-md-4">
<label>State </label>
<div class="form-group">
<asp:DropDownList class="form-control" ID="DropDownList1" runat="server">
<asp:ListItem Text="Select" Value="Select" />
<asp:ListItem>Arunachal Pradesh</asp:ListItem>
<asp:ListItem>Andra Pradesh</asp:ListItem>
<asp:ListItem>Assam</asp:ListItem>
<asp:ListItem>Bihar</asp:ListItem>
<asp:ListItem>Chhattisgarh</asp:ListItem>
<asp:ListItem>Rajasthan</asp:ListItem>
<asp:ListItem>Goa</asp:ListItem>
<asp:ListItem>Gujarat</asp:ListItem>
<asp:ListItem>Haryana</asp:ListItem>
<asp:ListItem>Himachal Pradesh</asp:ListItem>
<asp:ListItem>Jammu and Kashmir</asp:ListItem>
<asp:ListItem>Jharkhand</asp:ListItem>
<asp:ListItem>Karnataka</asp:ListItem>
<asp:ListItem>Kerela</asp:ListItem>
<asp:ListItem>Madhya Pradesh</asp:ListItem>
<asp:ListItem>Maharashtra</asp:ListItem>
<asp:ListItem>Odisa</asp:ListItem>
<asp:ListItem>Sikkim</asp:ListItem>
<asp:ListItem>Punjab</asp:ListItem>
<asp:ListItem>Tamil Nadu</asp:ListItem>
<asp:ListItem>West Bengal</asp:ListItem>
</asp:DropDownList>
</div>
</div>
<div class="col-md-4">
<label>City : </label>
<div class="form-group">
<asp:TextBox Class="form-control" ID="TextBox6" runat="server" Placeholder="City"></asp:TextBox>
</div>
</div>
<div class="col-md-4">
<label>PinCode : </label>
<div class="form-group">
<asp:TextBox CssClass="form-control" ID="TextBox7" runat="server" Placeholder="Pincode" TextMode="Number"></asp:TextBox>
</div>
</div>
</div>
<br>
<div class="row">
<div class="col">
<label>Full Address: </label>
<div class="form-group">
<asp:TextBox CssClass="form-control" ID="TextBox5" runat="server" Placeholder="Full Address" TextMode="MultiLine"></asp:TextBox>
</div>
</div>
</div>
<br>
<div class="row">
<div class="col">
<span class="badge rounded-pill bg-warning text-dark">New Login Credentials</span>
</div>
</div>
<br>
<div class="row">
<div class="col-md-6">
<label>Member ID : </label>
<div class="form-group">
<asp:TextBox Class="form-control" ID="TextBox8" runat="server" Placeholder="Member ID"></asp:TextBox>
</div>
</div>
<div class="col-md-6">
<label>Password : </label>
<div class="form-group">
<asp:TextBox CssClass="form-control" ID="TextBox9" runat="server" Placeholder="Password" TextMode="Password"></asp:TextBox>
</div>
</div>
</div>
<div class="row">
<div class="col" style="width:100%;">
<br>
<div class="form-group">
<center>
<%--<asp:Button class="btn btn-success btn-block btn-lg" style="width:510px;" ID="SignUp" runat="server" Text="Sign Up" OnClick="SignUp_Click" />--%>
<asp:Button class="btn btn-success btn-block btn-lg" style="width:510px;" ID="Button1" runat="server" Text="SignUp" OnClick="Button1_Click" />
</center>
</div>
</div>
</div>
</div>
</div>
<< Back To Home
</div>
</div>
</div>
</asp:Content>
Here is my usersignup.aspx.cs file
using System;
using System.Configuration;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Configuration;
namespace BookManagement
{
public partial class usersignup : System.Web.UI.Page
{
string strcon = WebConfigurationManager.ConnectionStrings["con"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
if (checkMemberExists())
{
Response.Write("<script>alert('Member Already Exists.Try Again!!!');</script>");
}
else
{
signUpNewMember();
}
}
bool checkMemberExists()
{
try
{
SqlConnection con = new SqlConnection(strcon);
if (con.State == ConnectionState.Closed)
{
con.Open();
}
SqlCommand cmd = new SqlCommand("SELECT * FROM member_master_tabel WHERE member_id='"+TextBox8.Text.Trim()+"';", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count >= 1)
{
return true;
}
else
{
return false;
}
//cmd.ExecuteNonQuery();
con.Close();
Response.Write("<script>alert('signup is successful. Go to the login page.');</script>");
}
catch (Exception ex)
{
Response.Write("<script>alert('" + ex.Message + "');</script>");
return false;
}
}
void signUpNewMember()
{
try
{
SqlConnection con = new SqlConnection(strcon);
if (con.State == ConnectionState.Closed)
{
con.Open();
}
SqlCommand cmd = new SqlCommand("INSERT INTO member_master_tabel(full_name,dob,contact_no,email,state,city,pincode,full_address,member_id,password,account_status)" +
"VALUES(#full_name,#dob,#contact_no,#email,#state,#city,#pincode,#full_address,#member_id,#password,#account_status)", con);
//SqlCommand cmd = new SqlCommand("INSERT INTO member_master_tabel VALUES('abhay', '11-10-2018', '1234567890', 'mail#demo.com', 'Gujarat', 'Ahmedabad', '380001', 'qwertytjfgnbvf', 'ts13', '456', 'pending');", con);
cmd.Parameters.AddWithValue("#full_name", TextBox1.Text.Trim());
cmd.Parameters.AddWithValue("#dob", TextBox2.Text.Trim());
cmd.Parameters.AddWithValue("#contact_no", TextBox3.Text.Trim());
cmd.Parameters.AddWithValue("#email", TextBox4.Text.Trim());
cmd.Parameters.AddWithValue("#state", DropDownList1.SelectedItem.Value);
cmd.Parameters.AddWithValue("#city", TextBox6.Text.Trim());
cmd.Parameters.AddWithValue("#pincode", TextBox7.Text.Trim());
cmd.Parameters.AddWithValue("#full_address", TextBox5.Text.Trim());
cmd.Parameters.AddWithValue("#member_id", TextBox8.Text.Trim());
cmd.Parameters.AddWithValue("#password", TextBox9.Text.Trim());
cmd.Parameters.AddWithValue("#account_status", "pending");
cmd.ExecuteNonQuery();
con.Close();
Response.Write("<script>alert('signup is successful. Go to the login page.');</script>");
}
catch (Exception ex)
{
Response.Write("<script>alert('" + ex.Message + "');</script>");
}
}
}
}
Here is my web.config file :
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="con" connectionString="Data Source=PROBOOK-HP\SQLEXPRESS;Initial Catalog=ebookDB;Integerated Security=true" />
</connectionStrings>

Related

How to populate bootstrap modal using c# code?

I created a repeater control which displays data from the database. When the user click delete button it should fetch the respective column data from database and store it in the fields which is actually not happening.
I attached my entire code with this question.
Anyone please help me!
All other solutions available are based on only jQuery. But I want to do it through c#.
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Repeater.aspx.cs" Inherits="intern4.Repeater" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="repeaterstylesheet.css" />
</head>
<body>
<form id="form1" runat="server" >
<div>
<asp:Repeater ID="Repeater1" runat="server" >
<HeaderTemplate>
<div class="container align" >
<div class="row header">
<div class="col-sm-2">ID</div>
<div class="col-sm-2">Name</div>
<div class="col-sm-2">Class</div>
<div class="col-sm-2">Edit</div>
<div class="col-sm-2">Delete</div>
</div>
</HeaderTemplate>
<ItemTemplate>
<div class="row data">
<div class="col-sm-2"> <asp:Label ID="lblId" runat="server" Text='<%# Eval("StudentID") %>' /></div>
<div class="col-sm-2"><asp:Label ID="lblName" runat="server" Text='<%# Eval("StudentName") %>' /></div>
<div class="col-sm-2"><asp:Label ID="lblClassx" runat="server" Text='<%# Eval("StudentClass") %>' /></div>
<div class="col-sm-2">Edit</div>
<div class="col-sm-2">
<asp:LinkButton ID="linkbtn" runat="server" ClientIDMode="Static" CssClass="btn btn-primary" data-target="#exampleModalCenter"
data-toggle="modal" CommandArgument='<%# Eval("StudentID") %>' OnCommand="btn_clck" >
Delete
</asp:LinkButton>
</div>
</div>
<hr style="color:blue" />
</ItemTemplate>
<FooterTemplate>
</div>
</FooterTemplate>
</asp:Repeater>
</div>
<!-- Modal -->
<div class="modal fade" id="exampleModalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLongTitle">Conformation alert</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="form-group row">
<legend class="col-form-label col-sm-2 pt-0">ID</legend>
<div class="col-sm-10">
<div class="form-check">
<asp:label id="lblStudentID" runat="server" class="form-check-label" />
</div>
</div>
</div>
<div class="form-group row">
<label for="inputName" class="col-sm-2 col-form-label">Name</label>
<div class="col-sm-10">
<asp:TextBox ID="inputName" runat="server" class="form-control" Text=""></asp:TextBox>
</div>
</div>
<div class="form-group row">
<label for="inputClass" class="col-sm-2 col-form-label">Class</label>
<div class="col-sm-10">
<asp:TextBox ID="inputClass" runat="server" class="form-control" Text=""></asp:TextBox>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
<asp:Button runat="server" Text="yes" OnClick="Deletestudent" />
</div>
</div>
</div>
</div>
</form>
</body>
</html>
C# code
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace intern4
{
public partial class Repeater : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this.BindRepeater();
}
}
private void BindRepeater()
{
string constr = ConfigurationManager.ConnectionStrings["constring"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("SELECT StudentID, StudentName, StudentClass FROM tbl_Student", con))
{
using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
{
using (DataTable dt = new DataTable())
{
sda.Fill(dt);
Repeater1.DataSource = dt;
Repeater1.DataBind();
}
}
}
}
}
protected void Deletestudent(object sender, EventArgs e)
{
int studentId = int.Parse(((sender as Button).NamingContainer.FindControl("lblId") as Label).Text);
string constr = ConfigurationManager.ConnectionStrings["constring"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("DELETE FROM tbl_Student WHERE StudentID = #StudentId", con))
{
cmd.Parameters.AddWithValue("#StudentId", studentId);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
}
this.BindRepeater();
}
protected void btn_clck(object sender, CommandEventArgs e)
{
int s = int.Parse((sender as LinkButton).CommandArgument);
lblStudentID.Text = s.ToString();
string constr = ConfigurationManager.ConnectionStrings["constring"].ConnectionString;
SqlConnection con = new SqlConnection(constr);
con.Open();
try
{
SqlCommand cmd = new SqlCommand(
"select * from tbl_Student where StudentID=" + s + "", con);
SqlDataReader sd = cmd.ExecuteReader();
while (sd.Read())
{
inputName.Text = sd.GetValue(1).ToString();
inputClass.Text = sd.GetValue(2).ToString();
}
}
catch (SqlException ex)
{
}
con.Close();
}
}
}
According to this answer you have to add below code after setting the TextBox Controls:
//... Some other code
while (sd.Read()) {
inputName.Text = sd.GetValue(1).ToString();
inputClass.Text = sd.GetValue(2).ToString();
}
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append(#"<script type='text/javascript'>");
sb.Append("$('#exampleModalCenter').modal('show');");
sb.Append(#"</script>");
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "MyModel",
sb.ToString(), false);
This code will populate the Bootstrap Model from C# code-behind.

Retrieve Textbox value in asp.net ListView

I generating a listview (a list of products for user to make order) with a textbox inside. User may enter quantity of product that want to order in this textbox. I set the initial value of this textbox to 0. My issue is when user insert a new quantity value in this textbox and click submit button, it should retrieve the value that user insert, but it still retrieve the initial value which is 0. Below is my code, can anyone tell me which part of my code is incorrect?
HTML page
<div class="row">
<asp:Listview runat="server" ID="Listview1">
<ItemTemplate>
<div class="col-sm-6 col-md-4 col-lg-4" id="divRow">
<div class="wrap-listview-block">
<div class="listview-block-inner">
<div class="row">
<div class="col-xs-2 col-sm-3 col-md-3 col-lg-3">
<%--<img src="../images/img-product-gerbang-jingga.jpg">--%>
<telerik:RadBinaryImage runat="server" ID="RadBinaryImage1" DataValue='<%#Eval("ProductImg") %>' Width="80.02" Height="109.55"
AutoAdjustImageControlSize="false" ToolTip='<%#Eval("ProdCode", "Photo of {0}") %>'
AlternateText='<%#Eval("ProdCode", "Photo of {0}") %>' />
</div>
<div class="col-xs-10 col-sm-9 col-md-9 col-lg-9 listing-right">
<div class="caption">
<h3>(<%#Eval("ProdCode")%>) <%#Eval("ProdName")%> </h3>
<div class="btn-details">
<i class="fa fa-info-circle" aria-hidden="true"></i> <i class="fa fa-gift" aria-hidden="true"></i> <i class="fa fa-file-image-o" aria-hidden="true"></i> <i class="fa fa-book" aria-hidden="true"></i>
</div>
<div class="btn-details">
<form class="form-inline">
<%--<select class="form-control input-sm col-xs-6">
<option>Carton</option>
<option>Piece</option>
</select>--%>
<asp:DropDownList ID="ddlQuantity" runat="server" CssClass="form-control input-sm col-xs-6">
<asp:ListItem Value="1" Selected="True">Carton</asp:ListItem>
<asp:ListItem Value="2">Piece</asp:ListItem>
</asp:DropDownList>
<div class="input-group col-xs-6">
<span class="input-group-btn">
<asp:LinkButton runat="server" CssClass="btn btn-sm btn-sub" ID="btnDown"><i class="fa fa-minus" aria-hidden="true"></i></asp:LinkButton>
</span>
<asp:TextBox runat="server" ID="txtQuantity" CssClass="form-control input-sm text-right" Text="0" Width="90"></asp:TextBox>
<span class="input-group-btn">
<asp:LinkButton runat="server" CssClass="btn btn-sm btn-sub" ID="btnUp"><i class="fa fa-plus" aria-hidden="true"></i></asp:LinkButton>
</span>
<ajaxToolkit:NumericUpDownExtender ID="NumericUpDownExtender1" Runat="server" TargetControlID="txtQuantity" TargetButtonDownID="btnDown" TargetButtonUpID="btnUp"/>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div><!-- listing block -->
</div><!--Product block -->
</ItemTemplate>
</asp:Listview>
</div>
<div class="footer-bar">
<div class="row">
<div class="col-xs-12">
<asp:LinkButton runat="server" ID="btnProceedOrder" OnClick="btnProceedOrder_Click" >
<div class="footer-inner">
<span class='glyphicon glyphicon-shopping-cart' aria-hidden="true"></span>
<br />
<asp:Literal runat="server" ID="litProceedOrder" Text="<%$ Resources:Lang, ProceedOrder %>"></asp:Literal>
</div>
</asp:LinkButton>
</div>
</div>
</div>
Code Behind
protected void Page_Load(object sender, EventArgs e)
{
String UserName = Utils.Session.Get(Constants.SessionObjects.UserName);
if (!IsPostBack)
{
DataTable dt = this.GetData();
Listview1.DataSource = dt;
Listview1.DataBind();
}
}
private DataTable GetData()
{
string RetailLink = ConfigurationManager.ConnectionStrings["DefaultDB"].ConnectionString;
using (SqlConnection con = new SqlConnection(RetailLink))
{
using (SqlCommand cmd = new SqlCommand("EXEC sp_mProduct_Sel_ByPrincipalRetailer#PWA " + UserName + ", " + PricipalID.ToInt32()))
{
using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.Connection = con;
sda.SelectCommand = cmd;
using (DataTable dt = new DataTable())
{
sda.Fill(dt);
return dt;
}
}
}
}
}
protected void btnProceedOrder_Click(object sender, EventArgs e)
{
foreach (ListViewDataItem row in Listview1.Items)
{
TextBox txtQuantity = row.FindControl("txtQuantity") as TextBox;
string Quantity = txtQuantity.Text.ToString(); //string Quantity keep getting "0", I need to get the value that user insert.
}
}

how to get bootstrap textbox value in asp.net code behind and send as parameters in store procedure?

I have following code on customer.aspx page. Now how can I use textbox and dropdown button's values in codebehind file to send as parameter of the store procedure ? textbox and dropdown must be build from Bootstrap only
<div class=" col-xs-12 col-md-6 col-lg-4">
<div class="form-group">
<label for="firstname">First Name</label>
<input class="form-control" id="firstname" type="text" placeholder="Smith">
</div>
</div>
<div class=" col-xs-12 col-md-6 col-lg-4">
<div class="form-group">
<label for="gender">Gender</label>
<div class="form-group ">
<select class="form-control col-sm-10">
<option value="0" selected>Select Gender</option>
<option value="1">Male </option>
<option value="2">Female</option>
<option value="3">Others</option>
</select>
</div>
</div>
Codebehind file:
public void Enroll_Customer()
{
String CS =ConfigurationManager.ConnectionStrings["PortfolioMgmtConnectionString"].ConnectionString;
using (SqlConnection con = new SqlConnection(CS))
{
SqlCommand cmd = new SqlCommand("[spAddNewCustomer]", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("#FirstName", SqlDbType.VarChar).Value =
Request.Form("firstname");
cmd.Parameters.Add("#gender", SqlDbType.Text).Value = ddlCategory.SelectedValue;
con.Open();
cmd.executeNonQuery();
}
In ASP.NET Web Form, if we want to retrieve a control's data from postback, we want to use a server control as much as possible.
The main reason is it is not easy to maintain a control's state, unless you manipulate ViewState manually.
<div class="row">
<div class=" col-xs-12 col-md-6 col-lg-4">
<div class="form-group">
<asp:Label runat="server" ID="FirstNameLabel"
AssociatedControlId="FirstNameTextBox" Text="First Name"/>
<asp:TextBox runat="server" ID="FirstNameTextBox"
CssClass="form-control" placeholder="Smith" />
</div>
</div>
<div class=" col-xs-12 col-md-6 col-lg-4">
<div class="form-group">
<label for="gender">Gender</label>
<div class="form-group">
<asp:DropDownList runat="server" ID="GenderDropDownList"
CssClass="form-control">
<asp:ListItem Value="0" Text="Select Gender" Selected="True" />
<asp:ListItem Value="1" Text="Male" />
<asp:ListItem Value="2" Text="Female" />
<asp:ListItem Value="3" Text="Others" />
</asp:DropDownList>
</div>
</div>
</div>
</div>
Code Behind
public void Enroll_Customer()
{
string connectionString = ConfigurationManager
.ConnectionStrings["PortfolioMgmtConnectionString"].ConnectionString;
using (var conn = new SqlConnection(connectionString))
using (var cmd = new SqlCommand("spAddNewCustomer", conn))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("#FirstName", FirstNameTextBox.Text);
cmd.Parameters.AddWithValue("#Gender", GenderDropDownList.SelectedValue);
conn.Open();
cmd.ExecuteNonQuery();
}
}
If you want to use
Request.Form("firstname");
in your form, the input first name should have
name="firstname";
but in your form now, it just has id attribute.
It's not belong to bootstrap.

How to make data in textbox disappear with click of radio button?

I have this form where there is a dropdown list. When user select the list, the corresponding data appeared in the text boxes.
Now, I need to make the data disappear if the user clicks on the radio button - Yes in that section; not when user click submit at the end of the form.
My code below doesn't make the data disappear.
Here's my code that I have attempted :
protected void OtherVendor_SelectedIndexChanged(object sender, EventArgs e)
{
// use User entered infor - use Insert ?
if (OtherVendor.Text == "Yes")
{
txtSupplierEmail.Text = string.Empty;
txtSupplierName.Text = string.Empty;
txtSupplierName.Text = string.Empty;
txtSupplierCttPerson.Text = string.Empty;
txtSupplierCttNumber.Text = string.Empty;
txtSupplierEmail.Text = string.Empty;
txtSupplierName.Text = string.Empty;
txtSupplierCttPerson.Text = string.Empty;
txtSupplierCttNumber.Text = string.Empty;
}
}
And my html code :
<div class="row">
<div class="col-lg-12">
<div id="divAP"
class="panel panel-primary">
<div class="panel-heading">Supplier Information</div>
<div class="panel-body">
<div class="col-sm-6 col-lg-6">
<asp:UpdatePanel ID="UpdatePanel4"
runat="server">
<ContentTemplate>
<div class="form-group row">
<label class="col-md-4 control-label"
for="inputRefNo">Vendor :
<span style="color: red">*</span>
</label>
<div class="input-group col-md-8">
<asp:DropDownList ID="ddlSupplier"
OnSelectedIndexChanged="ddl1_SelectedIndexChanged"
runat="server"
CssClass="form-control"
AutoPostBack="true"></asp:DropDownList>
</div>
</div>
<div class="form-group row">
<label class="col-md-4 control-label"
for="radios">Others Vendor
<span style="color: red">*</span>
</label>
<div class="col-md-4">
<label class="col-md-4 control-label">
<asp:RadioButtonList ID="OtherVendor"
runat="server"
OnSelectedIndexChanged="OtherVendor_SelectedIndexChanged"
RepeatColumns="2"
RepeatDirection="Horizontal"
AutoPostBack="true">
<asp:ListItem Text="Yes"
value="Yes"></asp:ListItem>
<asp:ListItem Text="No"
value="No"></asp:ListItem>
</asp:RadioButtonList>
</label>
</div>
<%--To insert code for letting user filling up Supplier email - to have auto-pop up and enable overwrite etc. --%>
</div>
<div class="form-group row">
<label class="col-md-4 control-label"
for="inputRefNo">Vendor Email:
<span style="color: red">*</span>
</label>
<div class="col-md-4 control-label"
for="inputRefNo">
<asp:TextBox ID="txtSupplierEmail"
runat="server"
Text="Label"
Width="100%"
CssClass="form-control"></asp:TextBox>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
I'm not sure whether it is a typo or not, Anyway in your markup you were specified as AutoPostBck but actually it should be AutoPostBack; which means Bck should be Back
One more suggestion for you, instead of using OtherVendor.Text in your condition you can format the condition as like this:
if (OtherVendor.SelectedValue == "Yes")
{
// Clear controls here
}
else
{
// Do something else
}

How to make a tab control with bootstrap in asp.net

Here I am implementing bootstrap tab control in asp.net application.
1) On click on next i want to go to next tab.
I want to make tab control working by clicking on tabs of tab control to go to next tab or by clicking on next button.
<form id="form1" runat="server">
<div class="container">
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#personal">Personal Information</a></li>
<li><a data-toggle="tab" href="#professional">Professional Information</a></li>
<li><a data-toggle="tab" href="#accountinformation">User Account Infromation</a></li>
</ul>
<div class="tab-content">
<div id="personal" class="tab-pane fade in active">
<div class="form-group">
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-12">
<div class="col-sm-4">
<span class="Star-clr">*</span>First Name :
</div>
<div class="col-sm-8">
<asp:TextBox ID="txtName" runat="server" placeholder="First Name"</asp:TextBox>
</div>
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-12">
<div class="col-sm-2">
</div>
<div class="col-sm-10" style="float: right">
<asp:Button ID="btnNext" Width="150" runat="server" Text="NEXT" />
</div>
</div>
</div>
</div>
</div>
<div id="professional" class="tab-pane fade">
</div>
<div id="accountinformation" class="tab-pane fade">
</div>
</div>
</div>
</form>
Image of Tab control:
Create a button after your content divs and call function on this button
<input type="button" value="Next" onclick="ShowNextTab();" />
function ShowNextTab() {
if ($('.nav-tabs > .active').next('li').length == 0) //If you want to select first tab when last tab is reached
$('.nav-tabs > li').first().find('a').trigger('click');
else
$('.nav-tabs > .active').next('li').find('a').trigger('click');
}
Below is a complete solution
HTML
<form id="form1" runat="server">
<div class="container">
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#personal">Personal Information</a></li>
<li><a data-toggle="tab" href="#professional">Professional Information</a></li>
<li><a data-toggle="tab" href="#accountinformation">User Account Infromation</a></li>
</ul>
<div class="tab-content">
<div id="personal" class="tab-pane fade in active">
<div class="form-group">
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-12">
<div class="col-sm-4">
<span class="Star-clr">*</span>First Name :
</div>
<div class="col-sm-8">
<asp:TextBox ID="txtName" runat="server" placeholder="First Name"></asp:TextBox>//close tag is missing
</div>
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-12">
<div class="col-sm-2">
</div>
<div class="col-sm-10" style="float: right">
<asp:Button ID="btnNext" Width="150" runat="server" Text="NEXT" />
</div>
</div>
</div>
</div>
</div>
<div id="professional" class="tab-pane fade">
</div>
<div id="accountinformation" class="tab-pane fade">
</div>
<input type="button" value="Next" onclick="ShowNextTab();" />
<input type="button" value="Prev" onclick="ShowPrevTab();" />
</div>
</div>
</form>
JavaScript
function ShowNextTab() {
$('.nav-tabs > .active').next('li').find('a').trigger('click');
}
function ShowPrevTab() {
$('.nav-tabs > .active').prev('li').find('a').trigger('click');
}

Categories

Resources