TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sakshi Kaul
NA
72
7.2k
how to encrypt the EMPID
Apr 1 2019 7:58 AM
Hi
I want when user opens the registration form automatically he should get some value in EmpId field
for eg when he opens the registration form on portal to fill that he should get the following
page
http://localhost:50605/empid=1122000
I want empid in encrypted form in Url and lso want firstle all the feilds should be disabled once the user click edit button then only the user can enter or add the data
What changes should be done to the following 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.Sql;
using
System.Data.SqlClient;
using
System.Data;
using
System.Configuration;
public
partial
class
_Default : System.Web.UI.Page
{
SqlCommand cmd =
new
SqlCommand();
SqlConnection con =
new
SqlConnection();
protected
void
Page_Load(
object
sender, EventArgs e)
{
con.ConnectionString = @
"Data Source=SAKSHIKAUL-LT\SQLEXORESS1;Initial Catalog=registrationForm;Integrated Security=True"
;
con.Open();
{
if
(!
this
.IsPostBack)
Label1.Text =
""
;
}
}
protected
void
Button1_Click(
object
sender, EventArgs e)
{ SqlCommand cmd =
new
SqlCommand(
"insert into RegistrationTable"
+
"(EmpId,Nationality,Religion,Gender,Address,EmailId,Hobbies,MaritalStatus) values (@EmpId,@Nationality,@Religion,@Gender,@Address,@EmailId,@Hobbies,@MaritalStatus)"
, con);
//string insertQuery = "insert into RegistrationTable(EmpId,Nationality,Religion,Gender,Address,EmailId,Hobbies,Maritalstatus)values (@EmpId,@Nationality,@Religion,@Gender,@Address,@EmailId,@MHobbies,@Maritalstatus)";
cmd.Parameters.AddWithValue(
"@EmpId"
, TextBox1.Text);
cmd.Parameters.AddWithValue(
"@Nationality"
, TextBox2.Text);
cmd.Parameters.AddWithValue(
"@Religion"
, TextBox3.Text);
cmd.Parameters.AddWithValue(
"@Gender"
, TextBox4.Text);
cmd.Parameters.AddWithValue(
"@Address"
, TextBox5.Text);
cmd.Parameters.AddWithValue(
"@EmailId"
, TextBox6.Text);
cmd.Parameters.AddWithValue(
"@Hobbies"
, TextBox7.Text);
cmd.Parameters.AddWithValue(
"@Maritalstatus"
, TextBox8.Text);
cmd.ExecuteNonQuery();
Label1.Text =
"Registered Successfuly"
;
}
protected
void
Button2_Click(
object
sender, EventArgs e)
{
cmd.CommandText =
"update RegistrationTable set Nationality =' "
+ TextBox2.Text +
"' where EmpId='"
+ TextBox1.Text +
"' "
;
cmd.CommandText =
"update RegistrationTable set Religion =' "
+ TextBox3.Text +
"' where EmpId='"
+ TextBox1.Text +
"' "
;
cmd.CommandText =
"update RegistrationTable set Gender =' "
+ TextBox4.Text +
"' where EmpId='"
+ TextBox1.Text +
"' "
;
cmd.CommandText =
"update RegistrationTable set Address =' "
+ TextBox5.Text +
"' where EmpId='"
+ TextBox1.Text +
"' "
;
cmd.CommandText =
"update RegistrationTable set EmailId =' "
+ TextBox6.Text +
"' where EmpId='"
+ TextBox1.Text +
"' "
;
cmd.CommandText =
"update RegistrationTable set Hobbies =' "
+ TextBox7.Text +
"' where EmpId='"
+ TextBox1.Text +
"' "
;
cmd.CommandText =
"update RegistrationTable set MaritalStatus =' "
+ TextBox8.Text +
"' where EmpId='"
+ TextBox1.Text +
"' "
;
cmd.Connection = con;
cmd.ExecuteNonQuery();
Label1.Text =
"Updated Successfuly"
;
}
protected
void
Button3_Click(
object
sender, EventArgs e)
{
TextBox1.Text =
""
;
TextBox2.Text =
""
;
//set equal to empty string to all fields
TextBox3.Text =
""
;
//set equal to empty string to all fields
TextBox4.Text =
""
;
//set equal to empty string to all fields
TextBox5.Text =
""
;
//set equal to empty string to all fields
TextBox6.Text =
""
;
//set equal to empty string to all fields
TextBox7.Text =
""
;
//set equal to empty string to all fields
TextBox8.Text =
""
;
//set equal to empty string to all fields
Label1.Text =
"Clear All"
;
}
}
Reply
Answers (
1
)
Viewstate and postback handling
I am trying to show the count in a label based on the time