Introduction
Hi Friends ! After few hard work,Finally,I have made a Form Filling Application like IBPS or others.You can use this concepts on many places in your web application.I have gathered lots of information about this Form filling application from Internet and users then finally developed this application.I have solved some comments questions of users also in this applicaion .Now days every one is aware about form filling application because they fill online form Normally every day.If you Want to make a Large Project then you have to learn small -small concepts first.I have used many small concepts in this application which i have used in our previous post or others and Built this form filling application.I will show you what small concepts have been used in this application later.
How to use this form filling application:-
When User Run this Form Filling Application and fill all required fields details.
In this Application i have used following asp.net controls which are given below:-Hi Friends ! After few hard work,Finally,I have made a Form Filling Application like IBPS or others.You can use this concepts on many places in your web application.I have gathered lots of information about this Form filling application from Internet and users then finally developed this application.I have solved some comments questions of users also in this applicaion .Now days every one is aware about form filling application because they fill online form Normally every day.If you Want to make a Large Project then you have to learn small -small concepts first.I have used many small concepts in this application which i have used in our previous post or others and Built this form filling application.I will show you what small concepts have been used in this application later.
How to use this form filling application:-
When User Run this Form Filling Application and fill all required fields details.
- If users fill every details correctly which are already mentioned in Form and After that Press Submit&Save Button then one Registration Number will be generated.
- If users blank any fields then Submit&Save button will not work because i have used Validation controls.
- If user upload photo size greater than 25 kb and Signature size greater than 12 kb ,then it will show error.
- When user press Preview Button,then it will show complete details of user with photo and Signature, which he/she has filled in Form previously .
- An User can take print out of your application by clicking Click to Print Button on the form.
- An User can get your Admit Card by this Registration Number.
How many Asp.Net Controls have been Used in this Application:-
- Install Ajax Toolkit
- ToolkitScriptManager
- Calender Extender
- Table
- Radio Button
- FileUpload
- Button
- Label
- SqlDataSource
- Validation (RequiredFieldValidator and RegularExpressionValidator) control
- Image Control
What small concepts have been used in this Form filling application:-
- How to select one Radio Button and save selected value in database.
- How to link calender Extender control to TextBox.
- How to use FileUpload control for read and write data to the database.
- How to configure sql data source.
- How to add captcha control and validate with TextBox. More Details...
- How to add .mdf file on website and create a table with some columns.
- How to pass control value or variable value from one page to another page using session variable.
- How to set primary key constraints on a table column .More Details...
- How to generate registration number using c# and store it to database. More Details...
- How to Display image in image control.
- How to send Registration Number to the user's mail box using c#.
- How to insert image in database and display it to image control.
- How to solve sql injection problem in asp.net by the parameterized connection string. More Details...
- How to implement Exception handling concepts in any asp.net application. More Details...
- How to display current system date in label control.
- How to print any asp.net application using java script.
- How to allocate memory for any uploaded image in array.
- How to put restriction in image size when any user upload your image using FileUpload control.
- How to use validation control in asp.net application. More Details...
I have used this small -small concepts in this application.You can make many applications in asp.net by using this whole concepts .You can implement some extra features also in this application as given below:-
- Create a admin page by using Form Based Authentication Technique from here.
- Add a data List control for edit ,update,delete and cancel the clients records here.
- You can make profile page for every user like Facebook.
There are some steps to make this form filling application which are given below:-
Step 1 :- First open your visual studio -->File -->New-->website -->Select ASP.NET Empty website -->OK--> Open Solution Explorer -->Add a New Web Form (Default.aspx) as shown below:-
Step 2 :-Now Drag and Drop Table and Image control on the form (Default.aspx)-->after that open solution Explorer -->Right click on project Add New Folder -->Now copy an image from your desktop and paste in this folder-->Go properties of image control -->Open ImageUrl --> select Image as shown below:-
Step 3 :- Now Click OK Button -->You will see following Output as shown below:-
Note:- You can use Master page instead of this technique.
Step 4 :-Now Drag and Drop Table,Label,TextBox,Radio button,FileUpload,Button and SqlDataSource Controls on the form (default.aspx) as shown below:-
Step 5 :- Now Right click on each Radio Button -->Properties -->Set Group Name=Radio as shown below:-
Step 6 :- Link your Calendar Extender control with TextBox-->You have to follow for this here-->You will see following output as shown below:-
Step 7 :- Now Add captcha image on form from this post here -->you will see following output as shown below:-
Step 8 :- Now Add .mdf file --> create a New Table (students) and add columns as given below -->set primary key at sid column -->After that set Identity specification (Identity Increment =yes ) as shown below:-
Note :- You can refer following link for step as given below:-
- How to add .mdf database file on asp.net website
- How to solve sql server problems easily
- How to attach .mdf database in sql server easily
Step 9 :- Now open defualt.aspx page --> Configure your SqlDataSource -->choose connection strins(regconnectionStrings )-->select students table -->proceed with next Button -->click Finish as show below:-
Step 10 :- Now Double click on submit&save and Preview buttons -->Write the following c# codes as given below:-
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Data.SqlClient;
using System.Configuration;
using System.Net.Mail;
using System.Net;
public partial class _Default : System.Web.UI.Page
{
//Gerate a Unique Number...
public String characters = "0123456789";
public string UniqueNumber()
{
Random unique1 = new Random();
string s = "MNT";
int unique;
int n = 0;
while (n < 10)
{
if (n % 2 == 0)
{
s += unique1.Next(10).ToString();
}
else
{
unique = unique1.Next(52);
if (unique < this.characters.Length)
s = String.Concat(s, this.characters[unique]);
}
Label2.Text = s.ToString();
n++;
}
return s;
}
protected void Button1_Click1(object sender, EventArgs e)
{
String p = UniqueNumber();
//select one rado button value
string cast = null;
if (RadioButton1.Checked)
{
cast = "General";
}
else if (RadioButton2.Checked)
{
cast = "OBC";
}
else if (RadioButton3.Checked)
{
cast = "SC";
}
else if (RadioButton4.Checked)
{
cast = "ST";
}
else
{
cast = null;
}
// Allocate memory for image and signature
byte[] image_Byte = new byte[FileUpload1.PostedFile.InputStream.Length + 1];
FileUpload1.PostedFile.InputStream.Read(image_Byte, 0, image_Byte.Length);
byte[] sign_Byte = new byte[FileUpload2.PostedFile.InputStream.Length + 1];
FileUpload2.PostedFile.InputStream.Read(sign_Byte, 0, sign_Byte.Length);
//Check whether image size 25 kb and signature size 12 kb or not
long size_img = FileUpload1.PostedFile.InputStream.Length;
long size_sign = FileUpload2.PostedFile.InputStream.Length;
if (size_img > 25600 | size_sign > 12228)
{
Label1.Text = "Please Enter image size less than 25kb and Signature size less than 12kb.Your image and signature size(in byte) are:- "+size_img +',' +size_sign ;
Label2.Text = null;
}
else
{
//create connection string for save values to students table
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["regConnectionString"].ConnectionString);
con.Open();
SqlCommand cmd = new SqlCommand("insert into students values(@n,@a,@r,@b,@c,@d,@e,@f,@p,@q)", con);
cmd.Parameters.AddWithValue("n", Label2.Text);
cmd.Parameters.AddWithValue("a", TextBox1.Text);
cmd.Parameters.AddWithValue("r", cast);
cmd.Parameters.AddWithValue("b", TextBox5.Text);
cmd.Parameters.AddWithValue("c", TextBox2.Text);
cmd.Parameters.AddWithValue("d", TextBox3.Text);
cmd.Parameters.AddWithValue("e", TextBox4.Text);
cmd.Parameters.AddWithValue("f", TextBox6.Text);
cmd.Parameters.AddWithValue("p", image_Byte);
cmd.Parameters.AddWithValue("q", sign_Byte);
FileUpload Upload_image = (FileUpload)this.FindControl("FileUpload1");
FileUpload Upload_sign = (FileUpload)this.FindControl("FileUpload2");
// Store required control values to the session variables
Session["number"] = Label2.Text;
Session["name"] = TextBox1.Text;
Session["category"] = cast;
Session["dob"] = TextBox5.Text;
Session["mobile"] = TextBox2.Text;
Session["qualification"] = TextBox3.Text;
Session["city"] = TextBox4.Text;
Session["email"] = TextBox6.Text;
captcha1.ValidateCaptcha(TextBox7.Text.Trim());
try
{
if (Upload_image.HasFile && Upload_sign.HasFile && captcha1.UserValidated)
{
int i = cmd.ExecuteNonQuery();
if (i > 0)
{
// Send Regisration number to user's mail box after submitting the form successfully
SmtpClient smtpc = new SmtpClient("smtp.gmail.com");
smtpc.Port = 587;
smtpc.EnableSsl = true;
smtpc.UseDefaultCredentials = false;
string user = "aryasamaj348@gmail.com"; //<--Enter your gmail id here
string pass = "9093870962";//<--Enter Your gmail password here
string sub = "Form filling Application:"; //Subject for your website
string msg = "Webcome to http://msdotnet.co.in Your Registration Number is: " + Label2.Text; //Message body
smtpc.Credentials = new NetworkCredential(user, pass);
MailMessage email = new MailMessage(user, TextBox6.Text, sub, msg);
smtpc.Send(email);
Label1.Text = "Your form has been submitted successfully.TakePreview Now,Your Registration Number is: ";
Label3.Text = null;
}
else
{
Label1.Text = "Your form has been not submitted successfully try again later";
Label3.Text = null;
Label2.Text = null;
}
}
else
{
Label3.ForeColor = System.Drawing.Color.Red;
Label3.Text = "Enter Valid Captcha code";
Label2.Text = null;
}
}
catch (Exception ex)
{
Label1.Text = ex.Message;
}
finally
{
con.Close();
}
}
}
protected void Button2_Click(object sender, EventArgs e)
{ // for goto default2.aspx page
Response.Redirect("Default2.aspx");
}
}
Description:- In above c# codes ,I have performed following steps which are already mentioned in the above c# codes in comment section. There are some steps which i have performed in this codes as given below;-
- First i have generate a unique Number and store it into Label 2 control.
- After that select one Radio Button value and store it to a 'cast' Variable.
- After that ,i have allocated memory of array for image size, signature size and Read its size value.
- After that i have checked whether image size is 25 kb and signature size is 12 kb or not.If user Upload any image greater than 25 and 12 kb then it will show error.i will show you it in below output section.
- After that created a sql connection strings for save the controls and variables values to the Students Table.
- After that Stored required fields(controls and variables) values to the session variables. Session variables basically are used to transfer the values from one page to another page.For More Here.
- After that send Registration Number to the respective user's mail box after submitting the application successfully.
Note:-Please put your gmail id and password in c# code section ,otherwise it will show some error.
Step 11 :- Now open Solution Explorer --> Add a New web form (default2.aspx)-->Drag and Drop Table control (add row and column) Labels and Image controls on the form as shown below:-Step 12 :-Now click Source button --> Add java script codes for print operation as given below:-
<head runat="server">
<title></title>
<script type="text/javascript">
function print_page()
{
window.print();
}
</script>
</head>
<div>
<a href="#" onclick="javascript :print_page();"><strong><span class="style1">Click to Print</span></strong></a>
</div>
Step 13 :- Now Press F7 and write the following c# codes on the form(default.aspx.cs) as given below:-
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data.SqlClient;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ //declared the function
Retrieve_Image_signFromDB();
// holds the session variables
Label1.Text = Session["number"].ToString();
Label2.Text = Session["name"].ToString();
Label3.Text = Session["category"].ToString();
Label4.Text = Session["dob"].ToString();
Label5.Text = Session["mobile"].ToString();
Label6.Text = Session["qualification"].ToString();
Label7.Text = Session["city"].ToString();
Label8.Text = Session["email"].ToString();
Label9.Text = System.DateTime.Today.ToShortDateString().ToString();
}
private void Retrieve_Image_signFromDB()
{
//Retriev the image url by the default3 and default4 page
Image1.ImageUrl = "Default3.aspx";
Image2.ImageUrl = "Default4.aspx";
}
}
Step 14 :- Now open your Solution Explorer -->Add a New web Form (default3.aspx)-->press F 7 -->Write the c# codes in default3.aspx.cs file as given below:-
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data.SqlClient;
public partial class Default3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["regConnectionString"].ConnectionString);
con.Open();
SqlCommand cmd = new SqlCommand("select image from students where [reg_no] ='" + Session["number"].ToString()+ "'", con);
SqlDataReader dr = cmd.ExecuteReader();
//we have to typecast to byte[] before feeding it to BinaryWrite method.
if (dr.Read())
{
Response.BinaryWrite((byte[])dr["image"]);
}
con.Close();
}
}
Step 15 :- Now open your solution explorer again-->Add a New web Form (default4.aspx)-->press F 7 -->Write the c# codes in default4.aspx.cs file as given below:-
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data.SqlClient;
public partial class Default4 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["regConnectionString"].ConnectionString);
con.Open();
SqlCommand cmd = new SqlCommand("select sign from students where [reg_no] ='" + Session["number"].ToString()+ "'", con);
SqlDataReader dr = cmd.ExecuteReader();
//we have to typecast to byte[] before feeding it to BinaryWrite method.
if (dr.Read())
{
Response.BinaryWrite((byte[])dr["sign"]);
}
con.Close();
}
}
Description:- Why we use default3.aspx and default4.aspx form ?
Ans:-
- In this page ,i have written the c# codes which is used to fetch the image from student table with help of registration number.Here i want to receive image as an URL formt because image controls take values in URL format.
- I have passed registration number value by session variable to this page(default3.aspx and default4.aspx) .you can use query strings also for this operation.
Note:- First set Starup page as default.aspx otherwise it may show session variables error.Means Run default.aspx page first.
Step 17 :- Now press Submit&Save Button -->One Registration Number will be generated and displayed on the top of the page as shown below -->and One registration Number will be sent to your email id.
Step 18 :- Now open your email id which you have mentioned in form -->You will see one email is received with a registration Number as shown below:-
Note:-Check your spam or Junk folder also if you don't see it in your inbox.
Step 19 :- Now open your Database.mdf file from Solution Explorer -->Right click on students table -->press Show Table Data --> You will see following records in students table as shown below:-
Step 20 :- Now click Preview Button --> You will see following output as shown below:-
Step 21 :- Now Press Click to Print button -->You will see following output as shown below:-
Note :- Use Google Chrome Browser.It may better than other browsers. You can easily print and save the application as .PDF File. Check this PDF File here.
Step 22 :- Suppose any user upload image size greater than 25 kb or signature size greater than 12 kb then this application will give error as shown below:-
Step 23 :- If you want to run this whole web application directly on your visual studio then follow below steps which are given below:-
- First Download this whole application from bottom and Extract it-->Copy this whole file (cltr+c).
- Now open your visual studio --> File --.New --.website -->Select ASP.NET Empty website -->OK -->Now open Solution Explorer -->Right click on project -->Paste this whole application which you have copied previously.
- Now first Open Database.mdf file --.if it is showing error -->then delete this whole Databas.mdf file (otherwise no need to follow next steps) -->Now add another Database.mdf file -->Create New Table students with same column name as mentioned in step 8.
- Now Run the application-->then you can run this application successfully.
Note:- Suppose you want to build asp.net application for any organization then you have to follow two this which are helpful for security purpose.
- You have to change your TextBox ,Label ,FileUpload and others like this TextBox1.Text --change--> mytxt or Label1.Text --change --> lbmsg similarity follow other also.I have not changed it in post because user can understand this easily.
- Use parameterized connection strings in database connection always.
- Others security features also available but it is not free.So you have follow only above two technique.
For More...
- How to display image in Picture Box and save in database easily in windows forms application.
- How to find whether cookie is present in browser or not in asp.net
- How to Run Notepad Program easily using c#
- How to implement WCF Services in asp.net application
- How to implement Caching and ajax features in web services in asp.net
- How to implement web services in asp.net application
- How to implement Navigation control in asp.net application
- How to implement Transaction in sql server
- How to create setup file with sql database
- How to implement web form control in asp.net
- How to implement reflection concepts in c#
- How to implement file handling in asp.net application
- Real .NET Interview Questions and Answers
- How to host asp.net website on server free
- How to implement real oops concepts in. NET Application
- What are the basic elements used for compiling the c# codes
- How to create .dll file and use in asp.net application
- How to use secure login page in asp.net with example
- How to Add and verify Captcha image in 3 tier architecture in asp.net
- How to use virtual keyboard in asp.net for security purpose
- How to implement hashing concepts in asp.net
- Learn complete .Net Interview Questions and answers for job seekers
I hope this is helpful for you.
Please share this application and put your valuable comments.If you have confusion in any steps ,you can ask frequently.I will help you definitely .
Download Whole Attached Application
That's a good tutorial very help full. thank u !!!!!!
ReplyDeleteHow to make a crystal report in any asp.net application?
ReplyDeletehI Priya ! I have not yetvwritten any post on crystal report.So you have follow below link.
Deletehttp://www.codeproject.com/Questions/264855/how-to-create-simple-crystal-reports-in-asp-net-wi
I will post crystal report soon....wait.........
well,i appreciate ur efforts
ReplyDeletewell dear,i appreciate ur efforts
ReplyDeletedear i want to build an exe file in vs 2012 with c#.
pls help me
Hi Sanaullah ! All steps will be be same in vs 2012 Read Below link.
Deletehttp://www.msdotnet.co.in/2012/06/how-to-create-setup-fileexe-file-from.html
Play background music on page load in ASP.Net? please help me
DeleteGood Job sir
ReplyDeleteSir can you solve my problem for this error message. when i add data and click on submit button an error message will
ReplyDeleteraising. this is the error message->
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 25 - Connection string is not valid)
hi santose,
Deleteyou can solve this error:-
1.) use correct connection string name(Sql server name).
2.) don't assign string value in integer(meane use correct textbox for correct database column) .
3.) close the string after finish the operation.
You can try different connection strings from below link.
http://www.msdotnet.co.in/2013/12/how-to-use-different-connection-strings.html
Nice Post, Its really helpful for ASP .Net beginner. Thanks for posting this.
ReplyDeleteFrom- http://www.deltaitservices.in/websitedesign.aspx
i was use this content in my website but Error was come but i Not understand this
ReplyDeleteObject reference not set to an instance of an object. MNT075996...place give the sggestion
hi divya,
DeleteThis error means,you have not set correct parameter in your table column,suppose you want to insert a string value in integer data type column in your table,then it will be shown object reference is not set to an instance of an object. here your problem is same.
1.) first check number of fields in your form is same in your database table or not which you want to save in your table.
2.) Data type of each fields in your table should be matched correctly.
you have to save Label2.Text value in VAR data type in your database table, see step 10 carefully...
sir how i record and play audio onlinein asp.net and the recorder file saved in sql database
ReplyDeletesir i am a beginner for .net i want this source code for a complete referrence could u help me to learn asp
ReplyDeletesir while downloading your source code the 404 error is to be repeating please help me to get the source code
ReplyDeleteGood evening sir,
ReplyDeleteI'm facing a serious error by clicking on submit button. It says (Object reference not set to an instance of an object. OFC969493). I have checked the datas correctly and compared with the one in my database table to the form. But is still displaying same errors message
Good evening sir,
ReplyDeleteI'm facing a serious error by clicking on submit button. It says (Object reference not set to an instance of an object. OFC969493). I have checked the datas correctly and compared with the one in my database table to the form. But is still displaying same errors message
This means,some problems in your conection codes,check your data types and other codes also.
Delete