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;
using System.IO;
namespace Doon
{
public partial class _Default : System.Web.UI.Page
{
/// <summary>
/// Global Variable
/// </summary>
#region "Global Variable"
SqlCommand _SqlCmd;
SqlConnection _SqlCon = new SqlConnection(ConfigurationSettings.AppSettings["dbConnString"].ToString());
#endregion
/// <summary>
/// Event
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
#region "Events"
protected override void OnPreRender(EventArgs e)
{
ViewState["Index"] = Session["Index"];
}
protected void Page_Load(object sender, EventArgs e)
{
Response.Cache.SetCacheability(HttpCacheability.NoCache);
if (!IsPostBack)
{
ResetFields();
txtName.Focus();
Session["Index"] = Server.UrlEncode(System.DateTime.Now.ToString());
}
}
protected void imgbtnSubmit_Click(object sender, ImageClickEventArgs e)
{
try
{
if (Convert.ToString(Session["Index"]) == Convert.ToString(ViewState["Index"]))
{
if (InsertDoonInfo(txtName.Text.Trim(), txtEmail.Text.Trim(), txtContactNo.Text.Trim(),ddlCourse.SelectedItem.Text.Trim()))
{
ResetFields();
Session["Index"] = Server.UrlEncode(System.DateTime.Now.ToString());
Response.Redirect("http://www.Clint.in/", false);
// ClientScriptmana.RegisterStartupScript(Page.GetType,, "RedirectScript", "Window.location.href='http://www.Clint.in/'", true);
// Response.StatusCode = 301;
//Response.StatusDescription = "Moved Permanently";
//Response.RedirectLocation = "http://www.Clint.in/";
//Response.End();
}
}
}
catch (Exception ex)
{
HandleException(ex);
}
}
#endregion
/// <summary>
/// ResetFields
/// </summary>
#region "Events"
private void ResetFields()
{
txtName.Text = "";
txtEmail.Text = "";
txtContactNo.Text = "";
ddlCourse.SelectedIndex = -1;
}
#endregion
/// <summary>
/// InsertDoonInfo
/// </summary>
/// <returns></returns>
#region "InsertDoonInfo"
public Boolean InsertInfo(string _Name, string _Email, string _ContactNo,string _Courses)
{
try
{
_SqlCmd = new SqlCommand("USP_AddLandingInfo");
_SqlCmd.Parameters.AddWithValue("@Name", _Name);
_SqlCmd.Parameters.AddWithValue("@Email", _Email);
if (_ContactNo != string.Empty)
_SqlCmd.Parameters.AddWithValue("@ContactNo", _ContactNo);
if (_Courses != "-- Select Course --")
_SqlCmd.Parameters.AddWithValue("@Courses", _Courses);
_SqlCmd.CommandType = CommandType.StoredProcedure;
if (InsertRecordDB(_SqlCmd))
return true;
else
return false;
}
catch (Exception _Ex)
{
throw;
return false;
}
finally
{
_SqlCmd.Dispose();
}
}
#endregion
/// <summary>
/// InsertRecordDB
/// </summary>
/// <param name="_SqlCmd"></param>
/// <returns></returns>
#region "InsertRecordDB"
public Boolean InsertRecordDB(SqlCommand _SqlCmd)
{
try
{
if (_SqlCmd == null)
{
return false;
}
else if (_SqlCmd != null)
{
if (_SqlCon.State == ConnectionState.Closed)
{
_SqlCon.Open();
}
_SqlCmd.Connection = _SqlCon;
Int32 _RowAffect = _SqlCmd.ExecuteNonQuery();
if (_RowAffect == 1)
return true;
else
return false;
}
return true;
}
catch (Exception _Ex)
{
throw;
return false;
}
finally
{
if (_SqlCon.State == ConnectionState.Open)
{
_SqlCon.Close();
}
}
}
#endregion
/// <summary>
/// HandleException
/// </summary>
/// <param name="ex"></param>
#region "HandleException"
public void HandleException(Exception ex)
{
try
{
_SqlCmd = new SqlCommand("USP_LogError_Ins");
_SqlCmd.Parameters.AddWithValue("@Source", ex.Source);
_SqlCmd.Parameters.AddWithValue("@Message", ex.Message);
_SqlCmd.Parameters.AddWithValue("@TargetSite", ex.TargetSite.ToString());
//check the lenth of error and display last 900 charater to get proper information of error
if (ex.StackTrace.Length >= 890)
_SqlCmd.Parameters.AddWithValue("@StackTrace", ex.StackTrace.ToString().Substring((ex.StackTrace.Length - 890)));
else
_SqlCmd.Parameters.AddWithValue("@StackTrace", ex.StackTrace.ToString());
_SqlCmd.CommandType = CommandType.StoredProcedure;
if (InsertRecordDB(_SqlCmd))
{ }
}
catch (Exception _Ex)
{
LogErrorinFile(_Ex);
}
finally
{
_SqlCmd.Dispose();
}
}
#endregion
/// <summary>
/// LogErrorinFile
/// This method insert the exception in text file
/// </summary>
/// <param name="ex"></param>
#region "LogErrorinFile"
public void LogErrorinFile(Exception ex)
{
string _LogFilePath = HttpContext.Current.Server.MapPath("LogFile.txt");
string _MSG = string.Empty;
try
{
_MSG = ex.Source.ToString() + "==========" + ex.Message.ToString() + "==========" + ex.StackTrace.ToString() + "==========" + ex.TargetSite.ToString() + "==========" + System.DateTime.Now.ToString();
if (File.Exists(_LogFilePath))
{
File.AppendAllText(_LogFilePath, _MSG);
}
else
{
File.WriteAllText(_LogFilePath, _MSG);
}
}
catch { }
}
#endregion
}
}
--------------------------------------------------------------------------------------------------------------
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Doon._Default" ValidateRequest="false" %>
<!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>Doon Group of Colleges</title>
<style type="text/css">
body{
margin-top:0px;
background-color: #000000;
}
.doon-InputBox-06-06-11 {
font-family:Arial, Helvetica, sans-serif;
font-size:11px;
color:#000000;
width:240px;
}
.doon-select-06-06-11 {
font-family:Arial, Helvetica, sans-serif;
font-size:11px;
color:#000000;
width:245px;
}
.doon-textarea-06-06-11 {
font-family:Arial, Helvetica, sans-serif;
font-size:11px;
color:#000000;
width:150px;
}
.doon-txt-white-06-06-11 {
font-family:Arial, Helvetica, sans-serif;
font-size:12px;
font-weight:bold;
color:#000000;
}
.doon-txt-red-06-06-11 {
font-family:Arial, Helvetica, sans-serif;
font-size:16px;
font-weight:bold;
color:#ff0000;
text-decoration:none;
}
</style>
<script language="javascript" type="text/javascript" src="Javascript/IdeactsValidation.js"></script>
<script language="javascript" type="text/javascript">
window.history.forward();
function noBack(){ window.history.forward(); }
function PageUnload1()
{
document.getElementById('<%=hndFlag.ClientID %>').value="1";
document.getElementById("imgbtnSubmit").disabled=true;
}
function ResetAll()
{
document.getElementById("<%=txtName.ClientID %>").value="";
document.getElementById("<%=txtContactNo.ClientID %>").value="";
document.getElementById("<%=txtEmail.ClientID %>").value="";
document.getElementById("<%= ddlCourse.ClientID %>").value = '-- Select Course --';
document.getElementById('<%=hndFlag.ClientID %>').value="0";
document.getElementById("<%=txtName.ClientID %>").focus();
document.getElementById("imgbtnSubmit").disabled=false;
}
function Validation()
{
if(document.getElementById('<%=hndFlag.ClientID %>').value=="1")
return false;
document.getElementById('<%=hndFlag.ClientID %>').value="0";
if(Validatecheckforblank(document.getElementById("<%=txtName.ClientID %>"),'Name')==false)
return false;
if(ValidateCharectorForName(document.getElementById("<%=txtName.ClientID %>"),'Name')==false)
return false;
if(ValidateMobileNumber(document.getElementById("<%=txtContactNo.ClientID %>"),'Mobile No.')==false)
return false;
if(Validatecheckforblank(document.getElementById("<%=txtEmail.ClientID %>"),'Email ID')==false)
return false;
if(ValidateEmailID(document.getElementById("<%=txtEmail.ClientID %>"),'Email ID.')==false)
return false;
document.getElementById('<%=hndFlag.ClientID %>').value="1";
}
window.load=ResetAll;
</script>
</head>
<body onload="ResetAll();" onunload="PageUnload1();" onpageshow="if (event.persisted) noBack();">
<form id="form1" runat="server">
<table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="134" align="left" valign="top"><img src="images/header.gif" width="900" height="134" border="0" /></td>
</tr>
<tr>
<td height="272" align="left" valign="top"><img src="images/middle.gif" width="900" height="272" border="0" usemap="#doon_courses_map" /></td>
</tr>
<tr>
<td height="178" align="center" valign="top" style="background-image:url(images/footer.gif); background-repeat:no-repeat;"><table width="780" border="0" cellspacing="0" cellpadding="2">
<tr>
<td height="42" colspan="4" align="right" valign="top"><asp:HiddenField runat="server" ID="hndFlag" Value="0" /></td>
</tr>
<tr>
<td width="66" align="right" valign="top" class="doon-txt-white-06-06-11"><span class="doon-txt-red-06-06-11">*</span>Name:</td>
<td width="264" align="right" valign="top" class="doon-txt-white-06-06-11"><asp:TextBox ID="txtName" runat="server" onkeypress="javascript:return clickeventtest(event,'imgbtnSubmit');" MaxLength="85" CssClass="doon-InputBox-06-06-11"></asp:TextBox></td>
<td width="157" align="right" valign="top" class="doon-txt-white-06-06-11">Mobile No.:</td>
<td width="277" align="right" valign="top" class="doon-txt-white-06-06-11"><asp:TextBox ID="txtContactNo" MaxLength="11" onkeypress="javascript:return clickeventtest(event,'imgbtnSubmit');" runat="server" CssClass="doon-InputBox-06-06-11"></asp:TextBox></td>
</tr>
<tr>
<td height="7" colspan="4" align="right" valign="top"></td>
</tr>
<tr>
<td align="right" valign="top" class="doon-txt-white-06-06-11"><span class="doon-txt-red-06-06-11">*</span>Email ID:</td>
<td align="right" valign="top" class="doon-txt-white-06-06-11">
<asp:TextBox ID="txtEmail" MaxLength="85" runat="server" onkeypress="javascript:return clickeventtest(event,'imgbtnSubmit');" CssClass="doon-InputBox-06-06-11"></asp:TextBox></td>
<td align="right" valign="top" class="doon-txt-white-06-06-11">Course interested in:</td>
<td align="right" valign="top" class="doon-txt-white-06-06-11">
<asp:DropDownList ID="ddlCourse" runat="server" CssClass="doon-select-06-06-11">
<asp:ListItem Value="-- Select Course --">-- Select Course --</asp:ListItem>
<asp:ListItem Value="M.Sc. Biotechnology">M.Sc. Biotechnology</asp:ListItem>
<asp:ListItem Value="M.Sc. Microbiology">M.Sc. Microbiology</asp:ListItem>
<asp:ListItem Value="M.Sc. Biochemistry">M.Sc. Biochemistry</asp:ListItem>
<asp:ListItem Value="Master in Physiotherapy(MPT)">Master in Physiotherapy(MPT)</asp:ListItem>
<asp:ListItem Value="M.Sc. Medical Lab Technology">M.Sc. Medical Lab Technology</asp:ListItem>
<asp:ListItem Value="M.Sc. Pharma Chemistry">M.Sc. Pharma Chemistry</asp:ListItem>
<asp:ListItem Value="Bachelor of Physiotherapy (BPT)">Bachelor of Physiotherapy (BPT)</asp:ListItem>
<asp:ListItem Value="B.Sc. in Medical Microbiology(B.Sc.M.M)">B.Sc. in Medical Microbiology(B.Sc.M.M)</asp:ListItem>
<asp:ListItem value="B.Sc. In Medical Lab Technology">B.Sc. In Medical Lab Technology</asp:ListItem>
<asp:ListItem value="B.Sc. In Biotechnology (with BZ)">B.Sc. In Biotechnology (with BZ)</asp:ListItem>
<asp:ListItem value="Graduate Courses">Graduate Courses</asp:ListItem>
<asp:ListItem value="Computer Science & Engineering">Computer Science & Engineering</asp:ListItem>
<asp:ListItem Value="Electronics & Communication Engineering">Electronics & Communication Engineering</asp:ListItem>
<asp:ListItem Value="Automobile Engineering">Automobile Engineering</asp:ListItem>
<asp:ListItem Value="Chemical Engineering">Chemical Engineering</asp:ListItem>
<asp:ListItem Value="M.Sc. Biotechnology">M.Sc. Biotechnology</asp:ListItem>
<asp:ListItem Value="M.Sc. Microbiology">M.Sc. Microbiology</asp:ListItem>
<asp:ListItem Value="M.Sc. Forestry">M.Sc. Forestry</asp:ListItem>
<asp:ListItem Value="M.Sc. Agronomy">M.Sc. Agronomy</asp:ListItem>
<asp:ListItem Value="M.Sc. Horticulture">M.Sc. Horticulture</asp:ListItem>
<asp:ListItem Value="M.Sc. In Chemistry">M.Sc. In Chemistry</asp:ListItem>
<asp:ListItem Value="Master of Arts in Education(M.A.Ed.)">Master of Arts in Education(M.A.Ed.)</asp:ListItem>
<asp:ListItem Value="Masters of International Business">Masters of International Business</asp:ListItem>
<asp:ListItem Value="B.Sc. In Agriculture(B.Sc.Agri)">B.Sc. In Agriculture(B.Sc.Agri)</asp:ListItem>
<asp:ListItem Value="Bachelor of Science in Forestry">Bachelor of Science in Forestry</asp:ListItem>
<asp:ListItem Value="B.A .(Hons.)Mass Communication">B.A .(Hons.)Mass Communication</asp:ListItem>
<asp:ListItem Value="Bachelor of Library Science">Bachelor of Library Science</asp:ListItem>
<asp:ListItem Value="Bachelor of Education (B.Ed.)">Bachelor of Education (B.Ed.)</asp:ListItem>
<asp:ListItem Value="BBA in Hotel Management">BBA in Hotel Management</asp:ListItem>
<asp:ListItem Value="Bachelor in Business Administration">Bachelor in Business Administration</asp:ListItem>
<asp:ListItem Value="Bachelor of Computer Application(BCA)">Bachelor of Computer Application(BCA)</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td height="7" colspan="4" align="right" valign="top"></td>
</tr>
<tr>
<td colspan="4" align="right" valign="top"><asp:ImageButton ID="imgbtnSubmit"
ImageUrl="images/submit.gif" OnClientClick="javascript:return Validation();"
runat="server" width="147" height="39" onfocus="this.blur();"
onclick="imgbtnSubmit_Click"/></td>
</tr>
</table></td>
</tr>
</table>
<map name="doon_courses_map" id="doon_courses_map">
<area shape="rect" coords="41,3,854,265" href="http://www.ideacts.com/cms/page/rurl.aspx?TerminalID=0&TabID=0&Source=http://dpmc.in/&ID=2393" target="_blank" /></map>
</form>
</body>
</html>
--------------------------------------------------------------------------------------------------------------
////check blank textbox
function Validatecheckforblank(S1,msg)
{
var x=S1.value;
var FinalString=trimAll(x);
var bool=checkspace(FinalString)
if(FinalString == ''||bool==false)
{
alert(msg+' cannot be left blank.');
S1.value="";
S1.focus();
return false;
}
}
//for removing spaces
function checkspace(s1)
{
//var x=s1.value;
reWhiteSpace = new RegExp(/^\s+$/);
if (reWhiteSpace.test(s1))
{
return false;
}
}
//the following function used for triming the value
function trimAll(sString)
{
while (sString.substring(0,1) == ' ')
{
sString = sString.substring(1, sString.length);
}
while (sString.substring(sString.length-1, sString.length) == ' ')
{
sString = sString.substring(0,sString.length-1);
}
return sString;
}
function ValidatecheckforLength(S1,msg,len)
{
var x=S1.value.length;
if(x > len)
{
alert("Maximum length for "+ msg + " is "+len +" characters.");
S1.focus();
return false;
}
}
// added to check mobile numbers starting from all digits not only zero and 9
function ValidateMobileNumber(S1,msg)
{
var x=S1.value;
var num= parseFloat(trimAll(S1.value));
if(x!='')
{
var i;
for (i = 0; i < x.length; i++)
{
// Check that current character is number.
var c = x.charAt(i);
if (((c < "0") || (c > "9")))
{
alert("Please enter valid "+ msg+".")
S1.focus();
S1.value="";
return false;
}
}
if(num==0)
{
alert("Please enter valid "+ msg+".");
S1.focus();
S1.value="";
return false;
}
// Now it allows 12 digits in mobile number : HARISH 7-12-2009
if (x.length>11 ||x.length<10)
{
alert("Please enter 10 to 11 digits for "+msg+".");
S1.focus();
return false;
}
}
}
function ValidateLandLine(S1,msg)
{
if(S1.value.charAt(0)==' ')
{
alert('Space not allowed in the start of '+msg+'.');
S1.focus();
S1.value="";
return false;
}
var x=trimAll(S1.value);
if(x!='')
{
var num= parseFloat(trimAll(S1.value));
if(num==0)
{
alert("Please enter valid "+ msg+".")
S1.focus();
S1.value="";
return false;
}
var i;
for (i = 0; i < x.length; i++)
{
//Check that current character is number.
var c = x.charAt(i);
if (((c < "0") || (c > "9")))
{
alert("Please enter valid "+ msg+".")
S1.focus();
S1.value="";
return false;
}
}
if (x.charAt(0)!= 0)
{
alert(msg+" should start with 0.");
S1.value="";
S1.focus();
return false;
}
if (x.length > 12 ||x.length<10)
{
alert("Please enter 10 to 12 digits for "+msg+".");
S1.focus();
S1.value="";
return false;
}
}
}
//Validate EmailID
var bugchars = '!#$^&*()+|}{[]?><~%:;/,=`"\'';
function ValidateEmailID(str1,msg)
{
var str=str1.value;
var at="@"
var dot="."
var lat=str.indexOf(at)
var lstr=str.length
var ldot=str.indexOf(dot)
var lastdot=str.lastIndexOf(dot)
msg='Invalid ' + msg;
if (str.indexOf(at)==-1){
alert(msg);
str1.focus();
str1.value="";
return false
}
if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
alert(msg);
str1.focus();
str1.value="";
return false
}
if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr || str.substring(lastdot+1)==""){
alert(msg)
str1.focus();
str1.value="";
return false
}
if (str.indexOf(at,(lat+1))!=-1){
alert(msg);
str1.focus();
str1.value="";
return false
}
if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
alert(msg);
str1.focus();
str1.value="";
return false
}
if (str.indexOf(dot,(lat+2))==-1){
alert(msg);
str1.focus();
str1.value="";
return false
}
if (str.indexOf(" ")!=-1){
alert(msg);
str1.focus();
str1.value="";
return false
}
if(CharsInBag(str)==false){
alert(msg);
str1.focus();
str1.value="";
return false
}
var arrEmail=str.split("@")
var ldot=arrEmail[1].indexOf(".")
if(isInteger(arrEmail[1].substring(ldot+1))==false){
alert(msg);
str1.focus();
str1.value="";
return false
}
return true
}
function CharsInBag(s)
{ var i;
var lchar="";
// Search through string's characters one by one.
// If character is not in bag.
for (i = 0; i < s.length; i++)
{
// Check that current character isn't whitespace.
var c = s.charAt(i);
if(i>0)lchar=s.charAt(i-1)
if (bugchars.indexOf(c) != -1 || (lchar=="." && c==".")) return false;
}
return true;
}
function isInteger(s)
{ var i;
for (i = 0; i < s.length; i++)
{
// Check that current character is not a number.
var c = s.charAt(i);
if ((c >= "0") && (c <= "9") && (c != ".")) return false;
}
// All characters are numbers.
return true;
}
////validation for name only charector allowed
function ValidateCharectorForName(s1,msg)
{
var x=s1.value;
var mikExp = /[!\\$\\@\\\#%\^\&\*\(\)\[\]\<\>\+\_\{\}\`\~\=\|\?\:\;\,\.\/\'\"]/;
if(x.length > 0)
{
if(x.charAt(0)==' ')
{
alert('Space is not allowed in the start of '+msg+'.');
s1.focus();
s1.value="";
return false;
}
for(var i=0;i<x.length;i++)
{
var k=x.charAt(i);
if(k.search(mikExp) == 0)
{
alert('Please enter alpha character in '+msg+'.');
s1.focus();
s1.value="";
return false;
}
if(k.search('-') == 0)
{
alert('Please enter alpha character in '+msg+'.');
s1.focus();
s1.value="";
return false;
}
if(isNaN(k)|| k.indexOf(" ")!=-1)
{
//return true;;
}
else
{
alert('Please enter alpha character in '+msg+'.');
s1.focus();
s1.value="";
return false;
}
}
}
}
function clickeventtest(e, buttonid)
{
var evt = e ? e : window.event;
var bt = document.getElementById(buttonid);
if (bt)
{
if (evt.keyCode == 13)
{
bt.click();
return false;
}
}
}
function ValidateDropdownlist(S1,S1CampareValue,msg)
{
if(S1!=null)
{
if(S1.value==S1CampareValue)
{
alert('Please select '+msg+' from dropdown.');
S1.focus();
return false;
}
}
}
function GetRandomNumber(){
var sAxel = Math.random() + "";
var iNum = sAxel * 1000000000000000000;
return iNum;
}
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;
using System.IO;
namespace Doon
{
public partial class _Default : System.Web.UI.Page
{
/// <summary>
/// Global Variable
/// </summary>
#region "Global Variable"
SqlCommand _SqlCmd;
SqlConnection _SqlCon = new SqlConnection(ConfigurationSettings.AppSettings["dbConnString"].ToString());
#endregion
/// <summary>
/// Event
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
#region "Events"
protected override void OnPreRender(EventArgs e)
{
ViewState["Index"] = Session["Index"];
}
protected void Page_Load(object sender, EventArgs e)
{
Response.Cache.SetCacheability(HttpCacheability.NoCache);
if (!IsPostBack)
{
ResetFields();
txtName.Focus();
Session["Index"] = Server.UrlEncode(System.DateTime.Now.ToString());
}
}
protected void imgbtnSubmit_Click(object sender, ImageClickEventArgs e)
{
try
{
if (Convert.ToString(Session["Index"]) == Convert.ToString(ViewState["Index"]))
{
if (InsertDoonInfo(txtName.Text.Trim(), txtEmail.Text.Trim(), txtContactNo.Text.Trim(),ddlCourse.SelectedItem.Text.Trim()))
{
ResetFields();
Session["Index"] = Server.UrlEncode(System.DateTime.Now.ToString());
Response.Redirect("http://www.Clint.in/", false);
// ClientScriptmana.RegisterStartupScript(Page.GetType,, "RedirectScript", "Window.location.href='http://www.Clint.in/'", true);
// Response.StatusCode = 301;
//Response.StatusDescription = "Moved Permanently";
//Response.RedirectLocation = "http://www.Clint.in/";
//Response.End();
}
}
}
catch (Exception ex)
{
HandleException(ex);
}
}
#endregion
/// <summary>
/// ResetFields
/// </summary>
#region "Events"
private void ResetFields()
{
txtName.Text = "";
txtEmail.Text = "";
txtContactNo.Text = "";
ddlCourse.SelectedIndex = -1;
}
#endregion
/// <summary>
/// InsertDoonInfo
/// </summary>
/// <returns></returns>
#region "InsertDoonInfo"
public Boolean InsertInfo(string _Name, string _Email, string _ContactNo,string _Courses)
{
try
{
_SqlCmd = new SqlCommand("USP_AddLandingInfo");
_SqlCmd.Parameters.AddWithValue("@Name", _Name);
_SqlCmd.Parameters.AddWithValue("@Email", _Email);
if (_ContactNo != string.Empty)
_SqlCmd.Parameters.AddWithValue("@ContactNo", _ContactNo);
if (_Courses != "-- Select Course --")
_SqlCmd.Parameters.AddWithValue("@Courses", _Courses);
_SqlCmd.CommandType = CommandType.StoredProcedure;
if (InsertRecordDB(_SqlCmd))
return true;
else
return false;
}
catch (Exception _Ex)
{
throw;
return false;
}
finally
{
_SqlCmd.Dispose();
}
}
#endregion
/// <summary>
/// InsertRecordDB
/// </summary>
/// <param name="_SqlCmd"></param>
/// <returns></returns>
#region "InsertRecordDB"
public Boolean InsertRecordDB(SqlCommand _SqlCmd)
{
try
{
if (_SqlCmd == null)
{
return false;
}
else if (_SqlCmd != null)
{
if (_SqlCon.State == ConnectionState.Closed)
{
_SqlCon.Open();
}
_SqlCmd.Connection = _SqlCon;
Int32 _RowAffect = _SqlCmd.ExecuteNonQuery();
if (_RowAffect == 1)
return true;
else
return false;
}
return true;
}
catch (Exception _Ex)
{
throw;
return false;
}
finally
{
if (_SqlCon.State == ConnectionState.Open)
{
_SqlCon.Close();
}
}
}
#endregion
/// <summary>
/// HandleException
/// </summary>
/// <param name="ex"></param>
#region "HandleException"
public void HandleException(Exception ex)
{
try
{
_SqlCmd = new SqlCommand("USP_LogError_Ins");
_SqlCmd.Parameters.AddWithValue("@Source", ex.Source);
_SqlCmd.Parameters.AddWithValue("@Message", ex.Message);
_SqlCmd.Parameters.AddWithValue("@TargetSite", ex.TargetSite.ToString());
//check the lenth of error and display last 900 charater to get proper information of error
if (ex.StackTrace.Length >= 890)
_SqlCmd.Parameters.AddWithValue("@StackTrace", ex.StackTrace.ToString().Substring((ex.StackTrace.Length - 890)));
else
_SqlCmd.Parameters.AddWithValue("@StackTrace", ex.StackTrace.ToString());
_SqlCmd.CommandType = CommandType.StoredProcedure;
if (InsertRecordDB(_SqlCmd))
{ }
}
catch (Exception _Ex)
{
LogErrorinFile(_Ex);
}
finally
{
_SqlCmd.Dispose();
}
}
#endregion
/// <summary>
/// LogErrorinFile
/// This method insert the exception in text file
/// </summary>
/// <param name="ex"></param>
#region "LogErrorinFile"
public void LogErrorinFile(Exception ex)
{
string _LogFilePath = HttpContext.Current.Server.MapPath("LogFile.txt");
string _MSG = string.Empty;
try
{
_MSG = ex.Source.ToString() + "==========" + ex.Message.ToString() + "==========" + ex.StackTrace.ToString() + "==========" + ex.TargetSite.ToString() + "==========" + System.DateTime.Now.ToString();
if (File.Exists(_LogFilePath))
{
File.AppendAllText(_LogFilePath, _MSG);
}
else
{
File.WriteAllText(_LogFilePath, _MSG);
}
}
catch { }
}
#endregion
}
}
--------------------------------------------------------------------------------------------------------------
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Doon._Default" ValidateRequest="false" %>
<!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>Doon Group of Colleges</title>
<style type="text/css">
body{
margin-top:0px;
background-color: #000000;
}
.doon-InputBox-06-06-11 {
font-family:Arial, Helvetica, sans-serif;
font-size:11px;
color:#000000;
width:240px;
}
.doon-select-06-06-11 {
font-family:Arial, Helvetica, sans-serif;
font-size:11px;
color:#000000;
width:245px;
}
.doon-textarea-06-06-11 {
font-family:Arial, Helvetica, sans-serif;
font-size:11px;
color:#000000;
width:150px;
}
.doon-txt-white-06-06-11 {
font-family:Arial, Helvetica, sans-serif;
font-size:12px;
font-weight:bold;
color:#000000;
}
.doon-txt-red-06-06-11 {
font-family:Arial, Helvetica, sans-serif;
font-size:16px;
font-weight:bold;
color:#ff0000;
text-decoration:none;
}
</style>
<script language="javascript" type="text/javascript" src="Javascript/IdeactsValidation.js"></script>
<script language="javascript" type="text/javascript">
window.history.forward();
function noBack(){ window.history.forward(); }
function PageUnload1()
{
document.getElementById('<%=hndFlag.ClientID %>').value="1";
document.getElementById("imgbtnSubmit").disabled=true;
}
function ResetAll()
{
document.getElementById("<%=txtName.ClientID %>").value="";
document.getElementById("<%=txtContactNo.ClientID %>").value="";
document.getElementById("<%=txtEmail.ClientID %>").value="";
document.getElementById("<%= ddlCourse.ClientID %>").value = '-- Select Course --';
document.getElementById('<%=hndFlag.ClientID %>').value="0";
document.getElementById("<%=txtName.ClientID %>").focus();
document.getElementById("imgbtnSubmit").disabled=false;
}
function Validation()
{
if(document.getElementById('<%=hndFlag.ClientID %>').value=="1")
return false;
document.getElementById('<%=hndFlag.ClientID %>').value="0";
if(Validatecheckforblank(document.getElementById("<%=txtName.ClientID %>"),'Name')==false)
return false;
if(ValidateCharectorForName(document.getElementById("<%=txtName.ClientID %>"),'Name')==false)
return false;
if(ValidateMobileNumber(document.getElementById("<%=txtContactNo.ClientID %>"),'Mobile No.')==false)
return false;
if(Validatecheckforblank(document.getElementById("<%=txtEmail.ClientID %>"),'Email ID')==false)
return false;
if(ValidateEmailID(document.getElementById("<%=txtEmail.ClientID %>"),'Email ID.')==false)
return false;
document.getElementById('<%=hndFlag.ClientID %>').value="1";
}
window.load=ResetAll;
</script>
</head>
<body onload="ResetAll();" onunload="PageUnload1();" onpageshow="if (event.persisted) noBack();">
<form id="form1" runat="server">
<table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="134" align="left" valign="top"><img src="images/header.gif" width="900" height="134" border="0" /></td>
</tr>
<tr>
<td height="272" align="left" valign="top"><img src="images/middle.gif" width="900" height="272" border="0" usemap="#doon_courses_map" /></td>
</tr>
<tr>
<td height="178" align="center" valign="top" style="background-image:url(images/footer.gif); background-repeat:no-repeat;"><table width="780" border="0" cellspacing="0" cellpadding="2">
<tr>
<td height="42" colspan="4" align="right" valign="top"><asp:HiddenField runat="server" ID="hndFlag" Value="0" /></td>
</tr>
<tr>
<td width="66" align="right" valign="top" class="doon-txt-white-06-06-11"><span class="doon-txt-red-06-06-11">*</span>Name:</td>
<td width="264" align="right" valign="top" class="doon-txt-white-06-06-11"><asp:TextBox ID="txtName" runat="server" onkeypress="javascript:return clickeventtest(event,'imgbtnSubmit');" MaxLength="85" CssClass="doon-InputBox-06-06-11"></asp:TextBox></td>
<td width="157" align="right" valign="top" class="doon-txt-white-06-06-11">Mobile No.:</td>
<td width="277" align="right" valign="top" class="doon-txt-white-06-06-11"><asp:TextBox ID="txtContactNo" MaxLength="11" onkeypress="javascript:return clickeventtest(event,'imgbtnSubmit');" runat="server" CssClass="doon-InputBox-06-06-11"></asp:TextBox></td>
</tr>
<tr>
<td height="7" colspan="4" align="right" valign="top"></td>
</tr>
<tr>
<td align="right" valign="top" class="doon-txt-white-06-06-11"><span class="doon-txt-red-06-06-11">*</span>Email ID:</td>
<td align="right" valign="top" class="doon-txt-white-06-06-11">
<asp:TextBox ID="txtEmail" MaxLength="85" runat="server" onkeypress="javascript:return clickeventtest(event,'imgbtnSubmit');" CssClass="doon-InputBox-06-06-11"></asp:TextBox></td>
<td align="right" valign="top" class="doon-txt-white-06-06-11">Course interested in:</td>
<td align="right" valign="top" class="doon-txt-white-06-06-11">
<asp:DropDownList ID="ddlCourse" runat="server" CssClass="doon-select-06-06-11">
<asp:ListItem Value="-- Select Course --">-- Select Course --</asp:ListItem>
<asp:ListItem Value="M.Sc. Biotechnology">M.Sc. Biotechnology</asp:ListItem>
<asp:ListItem Value="M.Sc. Microbiology">M.Sc. Microbiology</asp:ListItem>
<asp:ListItem Value="M.Sc. Biochemistry">M.Sc. Biochemistry</asp:ListItem>
<asp:ListItem Value="Master in Physiotherapy(MPT)">Master in Physiotherapy(MPT)</asp:ListItem>
<asp:ListItem Value="M.Sc. Medical Lab Technology">M.Sc. Medical Lab Technology</asp:ListItem>
<asp:ListItem Value="M.Sc. Pharma Chemistry">M.Sc. Pharma Chemistry</asp:ListItem>
<asp:ListItem Value="Bachelor of Physiotherapy (BPT)">Bachelor of Physiotherapy (BPT)</asp:ListItem>
<asp:ListItem Value="B.Sc. in Medical Microbiology(B.Sc.M.M)">B.Sc. in Medical Microbiology(B.Sc.M.M)</asp:ListItem>
<asp:ListItem value="B.Sc. In Medical Lab Technology">B.Sc. In Medical Lab Technology</asp:ListItem>
<asp:ListItem value="B.Sc. In Biotechnology (with BZ)">B.Sc. In Biotechnology (with BZ)</asp:ListItem>
<asp:ListItem value="Graduate Courses">Graduate Courses</asp:ListItem>
<asp:ListItem value="Computer Science & Engineering">Computer Science & Engineering</asp:ListItem>
<asp:ListItem Value="Electronics & Communication Engineering">Electronics & Communication Engineering</asp:ListItem>
<asp:ListItem Value="Automobile Engineering">Automobile Engineering</asp:ListItem>
<asp:ListItem Value="Chemical Engineering">Chemical Engineering</asp:ListItem>
<asp:ListItem Value="M.Sc. Biotechnology">M.Sc. Biotechnology</asp:ListItem>
<asp:ListItem Value="M.Sc. Microbiology">M.Sc. Microbiology</asp:ListItem>
<asp:ListItem Value="M.Sc. Forestry">M.Sc. Forestry</asp:ListItem>
<asp:ListItem Value="M.Sc. Agronomy">M.Sc. Agronomy</asp:ListItem>
<asp:ListItem Value="M.Sc. Horticulture">M.Sc. Horticulture</asp:ListItem>
<asp:ListItem Value="M.Sc. In Chemistry">M.Sc. In Chemistry</asp:ListItem>
<asp:ListItem Value="Master of Arts in Education(M.A.Ed.)">Master of Arts in Education(M.A.Ed.)</asp:ListItem>
<asp:ListItem Value="Masters of International Business">Masters of International Business</asp:ListItem>
<asp:ListItem Value="B.Sc. In Agriculture(B.Sc.Agri)">B.Sc. In Agriculture(B.Sc.Agri)</asp:ListItem>
<asp:ListItem Value="Bachelor of Science in Forestry">Bachelor of Science in Forestry</asp:ListItem>
<asp:ListItem Value="B.A .(Hons.)Mass Communication">B.A .(Hons.)Mass Communication</asp:ListItem>
<asp:ListItem Value="Bachelor of Library Science">Bachelor of Library Science</asp:ListItem>
<asp:ListItem Value="Bachelor of Education (B.Ed.)">Bachelor of Education (B.Ed.)</asp:ListItem>
<asp:ListItem Value="BBA in Hotel Management">BBA in Hotel Management</asp:ListItem>
<asp:ListItem Value="Bachelor in Business Administration">Bachelor in Business Administration</asp:ListItem>
<asp:ListItem Value="Bachelor of Computer Application(BCA)">Bachelor of Computer Application(BCA)</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td height="7" colspan="4" align="right" valign="top"></td>
</tr>
<tr>
<td colspan="4" align="right" valign="top"><asp:ImageButton ID="imgbtnSubmit"
ImageUrl="images/submit.gif" OnClientClick="javascript:return Validation();"
runat="server" width="147" height="39" onfocus="this.blur();"
onclick="imgbtnSubmit_Click"/></td>
</tr>
</table></td>
</tr>
</table>
<map name="doon_courses_map" id="doon_courses_map">
<area shape="rect" coords="41,3,854,265" href="http://www.ideacts.com/cms/page/rurl.aspx?TerminalID=0&TabID=0&Source=http://dpmc.in/&ID=2393" target="_blank" /></map>
</form>
</body>
</html>
--------------------------------------------------------------------------------------------------------------
////check blank textbox
function Validatecheckforblank(S1,msg)
{
var x=S1.value;
var FinalString=trimAll(x);
var bool=checkspace(FinalString)
if(FinalString == ''||bool==false)
{
alert(msg+' cannot be left blank.');
S1.value="";
S1.focus();
return false;
}
}
//for removing spaces
function checkspace(s1)
{
//var x=s1.value;
reWhiteSpace = new RegExp(/^\s+$/);
if (reWhiteSpace.test(s1))
{
return false;
}
}
//the following function used for triming the value
function trimAll(sString)
{
while (sString.substring(0,1) == ' ')
{
sString = sString.substring(1, sString.length);
}
while (sString.substring(sString.length-1, sString.length) == ' ')
{
sString = sString.substring(0,sString.length-1);
}
return sString;
}
function ValidatecheckforLength(S1,msg,len)
{
var x=S1.value.length;
if(x > len)
{
alert("Maximum length for "+ msg + " is "+len +" characters.");
S1.focus();
return false;
}
}
// added to check mobile numbers starting from all digits not only zero and 9
function ValidateMobileNumber(S1,msg)
{
var x=S1.value;
var num= parseFloat(trimAll(S1.value));
if(x!='')
{
var i;
for (i = 0; i < x.length; i++)
{
// Check that current character is number.
var c = x.charAt(i);
if (((c < "0") || (c > "9")))
{
alert("Please enter valid "+ msg+".")
S1.focus();
S1.value="";
return false;
}
}
if(num==0)
{
alert("Please enter valid "+ msg+".");
S1.focus();
S1.value="";
return false;
}
// Now it allows 12 digits in mobile number : HARISH 7-12-2009
if (x.length>11 ||x.length<10)
{
alert("Please enter 10 to 11 digits for "+msg+".");
S1.focus();
return false;
}
}
}
function ValidateLandLine(S1,msg)
{
if(S1.value.charAt(0)==' ')
{
alert('Space not allowed in the start of '+msg+'.');
S1.focus();
S1.value="";
return false;
}
var x=trimAll(S1.value);
if(x!='')
{
var num= parseFloat(trimAll(S1.value));
if(num==0)
{
alert("Please enter valid "+ msg+".")
S1.focus();
S1.value="";
return false;
}
var i;
for (i = 0; i < x.length; i++)
{
//Check that current character is number.
var c = x.charAt(i);
if (((c < "0") || (c > "9")))
{
alert("Please enter valid "+ msg+".")
S1.focus();
S1.value="";
return false;
}
}
if (x.charAt(0)!= 0)
{
alert(msg+" should start with 0.");
S1.value="";
S1.focus();
return false;
}
if (x.length > 12 ||x.length<10)
{
alert("Please enter 10 to 12 digits for "+msg+".");
S1.focus();
S1.value="";
return false;
}
}
}
//Validate EmailID
var bugchars = '!#$^&*()+|}{[]?><~%:;/,=`"\'';
function ValidateEmailID(str1,msg)
{
var str=str1.value;
var at="@"
var dot="."
var lat=str.indexOf(at)
var lstr=str.length
var ldot=str.indexOf(dot)
var lastdot=str.lastIndexOf(dot)
msg='Invalid ' + msg;
if (str.indexOf(at)==-1){
alert(msg);
str1.focus();
str1.value="";
return false
}
if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
alert(msg);
str1.focus();
str1.value="";
return false
}
if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr || str.substring(lastdot+1)==""){
alert(msg)
str1.focus();
str1.value="";
return false
}
if (str.indexOf(at,(lat+1))!=-1){
alert(msg);
str1.focus();
str1.value="";
return false
}
if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
alert(msg);
str1.focus();
str1.value="";
return false
}
if (str.indexOf(dot,(lat+2))==-1){
alert(msg);
str1.focus();
str1.value="";
return false
}
if (str.indexOf(" ")!=-1){
alert(msg);
str1.focus();
str1.value="";
return false
}
if(CharsInBag(str)==false){
alert(msg);
str1.focus();
str1.value="";
return false
}
var arrEmail=str.split("@")
var ldot=arrEmail[1].indexOf(".")
if(isInteger(arrEmail[1].substring(ldot+1))==false){
alert(msg);
str1.focus();
str1.value="";
return false
}
return true
}
function CharsInBag(s)
{ var i;
var lchar="";
// Search through string's characters one by one.
// If character is not in bag.
for (i = 0; i < s.length; i++)
{
// Check that current character isn't whitespace.
var c = s.charAt(i);
if(i>0)lchar=s.charAt(i-1)
if (bugchars.indexOf(c) != -1 || (lchar=="." && c==".")) return false;
}
return true;
}
function isInteger(s)
{ var i;
for (i = 0; i < s.length; i++)
{
// Check that current character is not a number.
var c = s.charAt(i);
if ((c >= "0") && (c <= "9") && (c != ".")) return false;
}
// All characters are numbers.
return true;
}
////validation for name only charector allowed
function ValidateCharectorForName(s1,msg)
{
var x=s1.value;
var mikExp = /[!\\$\\@\\\#%\^\&\*\(\)\[\]\<\>\+\_\{\}\`\~\=\|\?\:\;\,\.\/\'\"]/;
if(x.length > 0)
{
if(x.charAt(0)==' ')
{
alert('Space is not allowed in the start of '+msg+'.');
s1.focus();
s1.value="";
return false;
}
for(var i=0;i<x.length;i++)
{
var k=x.charAt(i);
if(k.search(mikExp) == 0)
{
alert('Please enter alpha character in '+msg+'.');
s1.focus();
s1.value="";
return false;
}
if(k.search('-') == 0)
{
alert('Please enter alpha character in '+msg+'.');
s1.focus();
s1.value="";
return false;
}
if(isNaN(k)|| k.indexOf(" ")!=-1)
{
//return true;;
}
else
{
alert('Please enter alpha character in '+msg+'.');
s1.focus();
s1.value="";
return false;
}
}
}
}
function clickeventtest(e, buttonid)
{
var evt = e ? e : window.event;
var bt = document.getElementById(buttonid);
if (bt)
{
if (evt.keyCode == 13)
{
bt.click();
return false;
}
}
}
function ValidateDropdownlist(S1,S1CampareValue,msg)
{
if(S1!=null)
{
if(S1.value==S1CampareValue)
{
alert('Please select '+msg+' from dropdown.');
S1.focus();
return false;
}
}
}
function GetRandomNumber(){
var sAxel = Math.random() + "";
var iNum = sAxel * 1000000000000000000;
return iNum;
}
No comments:
Post a Comment