Respected Sir,
I have a page in which i m getting error "Name txtbox does not exist in current context".It means all the controls are giving error .
ASPX and ASPX.CS file are -
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.Mail;
using RichClass;
public partial class control_userdownloads : System.Web.UI.UserControl
{
adddownload ad = new adddownload();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
addnews adn = new addnews();
TABLE3.Visible = true;
dldown.Visible = false;
bindDownLoad();
}
if (Session["uname"].ToString() != "0")
{
TABLE3.Visible = false;
dldown.Visible = true;
}
}
public bool getNote(object objNote)
{
if (objNote == null || objNote == System.DBNull.Value || objNote.ToString() == " " || objNote.ToString() == "")
{
return false;
}
else
{
return true;
}
}
void bindDownLoad()
{
DataSet ds;
ds = ad.SelectAllCourse();
if (ds.Tables[0].Rows.Count > 0)
{
dldown.DataSource = ds;
dldown.DataBind();
}
else
{
dldown.Visible = false;
}
}
protected void dldown_ItemDataBound(object sender, DataListItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
}
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
if (degree().ToString() != "")
{
addnews ad = new addnews();
bool chk = ad.insertuser(txtname.Text, txtsdt.Text, txtFname.Text, txtemail.Text, txtphone.Text, txtMobile.Text, txtCity.Text, degree().ToString());
if (chk == true)
{
dldown.Visible = false;
showmessage("Congrats! Now you can download the available information!");
dldown.Visible = true;
TABLE3.Visible = false;
Session["uname"] = txtemail.Text.Trim();
showmessage("Congrats! Now you can download information. please check your e-mail!");
string uname = RichClass.Security.EncryptData(txtemail.Text.Trim());
string url = "http://www.shridharuniversity.ac.in/download.aspx?uname=" + uname + "";
sendmail();
usermail(url);
clrall();
}
else
{
showmessage("Your E-mail ID Already Exist!");
}
}
else
{
showmessage("Please check atleast one interested Degree!");
}
}
public void showmessage(string str)
{
ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "clientScript", " alert('" + str + "')", true);
}
public string degree()
{
string str = "";
foreach (ListItem ll in CheckBoxList1.Items)
{
if (ll.Selected == true)
{
str += ll.Text + ", ";
}
}
if (str == "")
{
}
else
{
str = str.Substring(0, str.Length - 2);
}
return str;
}
public void clrall()
{
txtname.Text = "";
txtsdt.Text = "";
txtFname.Text = "";
txtemail.Text = "";
txtphone.Text = "";
txtMobile.Text = "";
txtCity.Text = "";
}
protected void lnkNewUser_Click(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
addnews ad = new addnews();
bool chk = ad.selUser(TextBox1.Text);
if (chk == true)
{
dldown.Visible = true;
TABLE3.Visible = false;
Session["uname"] = TextBox1.Text;
}
else
{
showmessage("E-mail ID not matched! Please enter the below required information.");
}
}
protected void lnkLogin_Click(object sender, EventArgs e)
{
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
Response.Redirect("test.aspx");
}
public void sendmail()
{
string message = "<table><tr><td>Name:</td><td>" + txtname.Text + "</td></tr><tr><td>Date of Birth:</td><td>" + txtsdt.Text + "</td></tr><tr><td>Father's Name:</td><td>" + txtFname.Text + "</td></tr><tr><td>e-mail:</td><td>" + txtemail.Text + "</td></tr><tr><td >Phone No:</td><td>" + txtphone.Text + "</td></tr><tr><td> Mobile:</td><td>" + txtMobile + "</td></tr><tr> <td> City:</td><td> " + txtCity.Text + "</td></tr> <tr><td> Degree interested in</td> <td>" + degree().ToString() + "</td></tr></table>";
string smtpServer = "mail.webshree.com";
int cdoBasic = 1;
int cdoSendUsingPort = 2;
System.Web.Mail.MailMessage objMail = new System.Web.Mail.MailMessage();
objMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", smtpServer);
objMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", 25);
objMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", cdoSendUsingPort);
objMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", cdoBasic);
objMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "adminmail@webshree.com");
objMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "okmijn#215");
objMail.To = "info@shridharuniversity.ac.in";
objMail.Bcc = "webshri@gmail.com";
objMail.From = txtemail.Text;
objMail.Subject = "New Candidate@Download Section";
objMail.BodyFormat = MailFormat.Html;
objMail.Body = message;
try
{
SmtpMail.SmtpServer = "mail.webshree.com";
SmtpMail.Send(objMail);
}
catch (Exception ex)
{
}
}
public void usermail(string url)
{
string message = "<table border=0 cellpadding=0 cellspacing=0><tr><td> Dear " + txtname.Text + ",</td></tr><tr><td>Welcome to Shridhar University, for Download information please click below link:</td></tr><tr><td> " + url + "</td></tr></table>";
string smtpServer = "mail.webshree.com";
int cdoBasic = 1;
int cdoSendUsingPort = 2;
System.Web.Mail.MailMessage objMail = new System.Web.Mail.MailMessage();
objMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", smtpServer);
objMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", 25);
objMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", cdoSendUsingPort);
objMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", cdoBasic);
objMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "adminmail@webshree.com");
objMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "okmijn#215");
objMail.To = txtemail.Text.Trim();
objMail.Bcc = "webshri@gmail.com";
objMail.From = "info@shridharuniversity.ac.in";
objMail.Subject = "New Candidate@Download Section";
objMail.BodyFormat = MailFormat.Html;
objMail.Body = message;
try
{
SmtpMail.SmtpServer = "mail.webshree.com";
SmtpMail.Send(objMail);
}
catch (Exception ex)
{
}
}
}
.ASPX FILE IS--
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="userdownloads.ascx.cs" Inherits="control_userdownloads" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<table border="0" cellpadding="0" cellspacing="0" width="470" id="TABLE3" runat="server" >
<tr>
<td align="center">
<h3> If you already entered the below Information please enter only your Email.</h3></td>
</tr>
<tr>
<td>
<table id="TABLE2" runat="server" border="0" cellpadding="0" cellspacing="0" class="feedbackFrm" width="100%">
<tr>
<td width="150px">
E-mail*:</td>
<td>
<asp:TextBox ID="TextBox1" runat="server"><br /><asp:RequiredFieldValidator
ID="RequiredFieldValidator7" runat="server" ControlToValidate="TextBox1" Display="Dynamic"
ErrorMessage="Email Required!" ValidationGroup="sss"><asp:RegularExpressionValidator
ID="RegularExpressionValidator7" runat="server" ControlToValidate="TextBox1"
Display="Dynamic" ErrorMessage="Invalid Email!" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
ValidationGroup="sss"></td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Button ID="Button1" CssClass="btn" runat="server" Text="Submit" OnClick="Button1_Click" ValidationGroup="sss" /></td>
</tr>
<table width="100%" id="TABLE1" runat="server" border="0" cellpadding="0" cellspacing="0" class="feedbackFrm">
<tr>
<td width="150px">
Name*:</td>
<td>
<asp:TextBox ID="txtname" runat="server"><br /><asp:RequiredFieldValidator
ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtname" Display="Dynamic"
ErrorMessage="Name Required!" ValidationGroup="vldgrp"><asp:RegularExpressionValidator
ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtname" Display="Dynamic"
ErrorMessage="Invalid Name!" ValidationExpression="^[^<>%\/@#$]{3,50}$" ValidationGroup="vldgrp"></td>
</tr>
<tr>
<td>
Date of Birth*:</td>
<td>
<asp:TextBox ID="txtsdt" runat="server"><br />
<cc1:calendarextender id="CalendarExtender1" runat="server" format="d/M/yyyy" targetcontrolid="txtsdt">
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ControlToValidate="txtsdt"
Display="Dynamic" ErrorMessage="Date of Birth Required!" ValidationGroup="vldgrp">
<asp:RegularExpressionValidator ID="RegularExpressionValidator6" runat="server" ControlToValidate="txtsdt"
Display="Dynamic" ErrorMessage="Date of Birth!" ValidationExpression="^[^<>%\@#$]{3,50}$"
ValidationGroup="vldgrp"></td>
</tr>
<tr>
<td>
Father's Name*:</td>
<td>
<asp:TextBox ID="txtFname" runat="server"><br /><asp:RequiredFieldValidator
ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtFname" Display="Dynamic"
ErrorMessage="Father's Name Required!" ValidationGroup="vldgrp"><asp:RegularExpressionValidator
ID="RegularExpressionValidator2" runat="server" ControlToValidate="txtFname"
Display="Dynamic" ErrorMessage="Invalid Father's Name !" ValidationExpression="^[^<>%\/@#$]{3,50}$"
ValidationGroup="vldgrp"></td>
</tr>
<tr>
<td>
E-mail*:</td>
<td>
<asp:TextBox ID="txtemail" runat="server"><br /><asp:RequiredFieldValidator
ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtemail" Display="Dynamic"
ErrorMessage="Email Required!" ValidationGroup="vldgrp"><asp:RegularExpressionValidator
ID="RegularExpressionValidator3" runat="server" ControlToValidate="txtemail"
Display="Dynamic" ErrorMessage="Invalid Email!" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
ValidationGroup="vldgrp"></td>
</tr>
<tr>
<td>
Phone No*:</td>
<td>
<asp:TextBox ID="txtphone" runat="server"><br /><asp:regularexpressionvalidator
id="RegularExpressionValidator9" runat="server" controltovalidate="txtphone"
display="Dynamic" errormessage="Invalid Phone" validationexpression="^[0-9-]{6,100}$"
validationgroup="vldgrp">
<asp:requiredfieldvalidator id="RequiredFieldValidator14" runat="server" controltovalidate="txtphone"
display="Dynamic" errormessage="Enter Phone!" validationgroup="vldgrp">
</td>
</tr>
<tr>
<td>
Mobile*:</td>
<td>
<asp:TextBox ID="txtMobile" runat="server"><br /><asp:RegularExpressionValidator
ID="Regularexpressionvalidator4" runat="server" ControlToValidate="txtMobile"
Display="Dynamic" ErrorMessage="Invalid Mobile" ValidationExpression="^[0-9-]{10,100}$"
ValidationGroup="vldgrp">
<asp:RequiredFieldValidator ID="Requiredfieldvalidator4" runat="server" ControlToValidate="txtMobile"
Display="Dynamic" ErrorMessage="Enter Mobile!" ValidationGroup="vldgrp"></td>
</tr>
<tr>
<td>
City*:</td>
<td>
<asp:TextBox ID="txtCity" runat="server"><br /><asp:RequiredFieldValidator
ID="RequiredFieldValidator5" runat="server" ControlToValidate="txtCity" Display="Dynamic"
ErrorMessage="City Required!" ValidationGroup="vldgrp"><asp:RegularExpressionValidator
ID="RegularExpressionValidator5" runat="server" ControlToValidate="txtCity" Display="Dynamic"
ErrorMessage="Invalid City!" ValidationExpression="^[^<>%\/@#$]{3,50}$" ValidationGroup="vldgrp"></td>
</tr>
<tr>
<td valign="top">
Degree interested in*</td>
<td valign="top">
<asp:CheckBoxList ID="CheckBoxList1" runat="server" RepeatColumns="5">
<asp:ListItem>Diploma
<asp:ListItem>UG
<asp:ListItem>PG
<asp:ListItem>Research
<asp:ListItem>Certificate
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Button ID="btnSubmit" runat="server" CssClass="btn" Text="Submit" OnClick="btnSubmit_Click" ValidationGroup="vldgrp" /></td>
</tr>
<tr>
<td>
</td>
<td>
</td>
</tr>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<asp:DataList ID="dldown" runat="server" RepeatColumns="1" OnItemDataBound="dldown_ItemDataBound" CssClass="dwnld"><itemtemplate>
<h3> <asp:HyperLink ID="hyp" runat="server" Text='<%# Eval("hd") %>' NavigateUrl='<%# "~/downloads/"+Eval("fname") %>' Target="_blank"></h3>
<p class="note" runat="server" id="noteid" visible='<%# getNote(Eval("nt")) %>'>
<asp:Label ID="lblnt" runat="server" Text='<%# "Note: " + Eval("nt")%>' visible='<%# getNote(Eval("nt")) %>'>
</itemtemplate>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
I am getting error while controls are on .aspx.
PLs help me out.
Thanks
Abhishek