Sujeet Raman

Sujeet Raman

  • 857
  • 927
  • 357.4k

Please help why controls name doesn't exist error!!

Aug 6 2016 1:27 AM
Hi all please help me am not able to find out the reason for why page controls does not exist..there is no error in my master page(its a copied solution for studying purpose)
version problems are fixed but still showing error(now working in VS 2013 the project version was 2.0)
 
 * one of my page
 
<pre lang="C#">using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Web.Security;
public partial class Loginaspx : System.Web.UI.Page
{
#region DATABASE_MEMBER
DataVariables objDataVar = new DataVariables();
DAL objDAL = new DAL();
LoginCredentials objLoginCred = new LoginCredentials();
LoginDAL objLoginDAL = new LoginDAL();
#endregion
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
bindUserType();
}
}
protected void btnCheck_Click1(object sender, EventArgs e)
{ }
/// &lt;summary&gt;
/// Login
/// &lt;/summary&gt;
/// &lt;param name=&quot;sender&quot;&gt;&lt;/param&gt;
/// &lt;param name=&quot;e&quot;&gt;&lt;/param&gt;
protected void btnLogin_Click(object sender, ImageClickEventArgs e)
{
try
{
// error in following control(txtusername etc)
objLoginCred.UserID = txtusername.Text.Trim();
objLoginCred.Password = txtPassword.Text.Trim();
objLoginCred.UserType = ddlUserType.SelectedItem.ToString();
/*Get records on the basis of use credentials*/
objDataVar.dtstEstOff = objLoginDAL.GetLogin(objLoginCred);
/*Check whether Fetched datatable HAS records or NOT */
if (objDataVar.dtstEstOff.Tables[0].Rows.Count &gt; 0)
{
Session[&quot;USERID&quot;] = objLoginCred.UserID;
Session[&quot;USERTYPE&quot;] = objLoginCred.UserType;
// Roles.CreateRole(&quot;members&quot;);
// Session[&quot;sitemap&quot;] = GetDataSource(objLoginCred.UserType, Server.MapPath(&quot;~&quot;));
if(!Roles.RoleExists(objLoginCred.UserType))
{
Roles.CreateRole(objLoginCred.UserType);
Roles.AddUserToRole(objLoginCred.UserID, objLoginCred.UserType);
}
Response.Redirect(&quot;~//HomePage.aspx&quot;, false);
}
else
{
ClientScript.RegisterStartupScript(GetType(), &quot;Error&quot;, &quot;alert('Invalid UserName / Password !')&quot;, true);
// Invalid UserName/Password
}
}
catch (Exception ex)
{ }
}
XmlDataSource GetDataSource(string UserRole, string ServerPath)
{
XmlDataSource objData = new XmlDataSource();
objData.XPath = &quot;siteMap/siteMapNode&quot;;
switch (UserRole)
{
case &quot;Administrator&quot;:
objData.DataFile = ServerPath + @&quot;/web.sitemap&quot;;
Roles.AddUserToRole(objLoginCred.UserType, &quot;Administrator&quot;);
break;
case &quot;Department&quot;:
objData.DataFile = ServerPath + @&quot;/Department.sitemap&quot;;
Roles.CreateRole(&quot;Department&quot;);
Roles.AddUserToRole(objLoginCred.UserType, &quot;Department&quot;);
break;
case &quot;Vendor&quot;:
objData.DataFile = ServerPath + @&quot;/User.sitemap&quot;;
Roles.CreateRole(&quot;Vendor&quot;);
Roles.AddUserToRole(objLoginCred.UserType, &quot;Vendor&quot;);
break;
default:
objData.DataFile = ServerPath + @&quot;/Default.sitemap&quot;;
break;
}
objData.DataBind();
return objData;
}
/// &lt;summary&gt;
///
/// &lt;/summary&gt;
public void bindUserType()
{
// error in following control(ddlusertype)
objDataVar.dtstEstOff = objLoginDAL.GetUserType();
// objDataVar.dtblEstOff= objDataVar.dtstEstOff.Tables[0];
ddlUserType.DataSource = objDataVar.dtstEstOff.Tables[0];
ddlUserType.DataTextField = &quot;UserType&quot;;
ddlUserType.DataValueField = &quot;UserType&quot;;
ddlUserType.DataBind();
}
}</pre>
//here is my current design page
<pre lang="ASP.NET">&amp;lt;%@ Page Title=&quot;&quot; Language=&quot;C#&quot; MasterPageFile=&quot;~/Master/SiteMain.master&quot; AutoEventWireup=&quot;true&quot; CodeFile=&quot;Login.aspx.cs&quot; Inherits=&quot;Loginaspx&quot; %&amp;gt;
&amp;lt;%@ Register Assembly=&quot;AjaxControlToolkit&quot; Namespace=&quot;AjaxControlToolkit&quot; TagPrefix=&quot;cc1&quot; %&amp;gt;
&amp;lt;asp:Content ID=&quot;Content1&quot; ContentPlaceHolderID=&quot;head&quot; runat=&quot;Server&quot;&amp;gt;
&amp;lt;asp:Content ID=&quot;Content2&quot; ContentPlaceHolderID=&quot;ContentPlaceHolder1&quot; runat=&quot;Server&quot;&amp;gt;
&lt;br /&gt;
&amp;lt;!--googleon: index--&amp;gt;
&lt;table height=&quot;410px&quot; id=&quot;loginContainer&quot; style=&quot;background-image: removed('Images/login-box-backg.png');&amp;lt;br mode=&quot; hold=&quot; /&amp;gt; clip: rect(50px, auto, auto, auto);&quot;&gt;
&lt;tr&gt;
&lt;td class=&quot;main&quot; align=&quot;center&quot; valign=&quot;top&quot;&gt;
&lt;table style=&quot;margin: 35px 0px 0px 0px; width: 415px;&quot;&gt;
&lt;tr&gt;
&lt;td style=&quot;margin: 50px;&quot; class=&quot;heading&quot;&gt;
&amp;lt;asp:Image runat=&quot;server&quot; ID=&quot;imgLogo&quot; ImageUrl=&quot;~/Images/IISc_logo_mncf_32.png&quot; /&amp;gt;
&amp;lt;asp:Label ID=&quot;label1&quot; runat=&quot;server&quot; Text=&quot;Login&quot;&amp;gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align=&quot;center&quot; class=&quot;UserType&quot;&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;td&gt;
&amp;lt;asp:Image ID=&quot;Image2&quot; runat=&quot;server&quot; ImageUrl=&quot;~/Images/user_cut.png&quot; /&amp;gt;
&lt;/td&gt;
&lt;td&gt;
&amp;lt;asp:Label ID=&quot;labelUserType&quot; runat=&quot;server&quot; Text=&quot;User Type&quot; Font-Bold=&quot;True&quot;&amp;gt;
&lt;/td&gt;
&lt;td&gt;
&amp;nbsp;
&lt;/td&gt;
&lt;td&gt;
&amp;lt;asp:DropDownList ID=&quot;ddlUserType&quot; runat=&quot;server&quot;&amp;gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align=&quot;left&quot; colspan=&quot;2&quot; class=&quot;vldEmail vldEmailLength vldMand&quot;&gt;
&amp;lt;asp:RequiredFieldValidator ID=&quot;RequiredFieldValidator2&quot; runat=&quot;server&quot; ErrorMessage=&quot;Enter user name!&quot;
ControlToValidate=&quot;txtUserName&quot; Font-Size=&quot;9pt&quot; ForeColor=&quot;#FF9900&quot; ValidationGroup=&quot;Login&quot;&amp;gt;*
&amp;lt;label for=&quot;EmailLogin&quot; class=&quot;Hidden&quot;&amp;gt;
&amp;lt;/label&amp;gt;
&amp;lt;asp:TextBox ID=&quot;txtusername&quot; TabIndex=&quot;1&quot; runat=&quot;server&quot; ForeColor=&quot;#96CDE0&quot; &amp;gt;
&amp;lt;%-- &lt;br /&gt;
&lt;span style=&quot;color: #EBEBEB&quot;&gt;(e.g. [email protected]&lt;/span&gt;--%&amp;gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align=&quot;left&quot; colspan=&quot;2&quot; class=&quot;vldEmail vldEmailLength vldMand&quot;&gt;
&amp;lt;asp:RequiredFieldValidator ID=&quot;RequiredFieldValidator1&quot; runat=&quot;server&quot; ErrorMessage=&quot;Enter valid password!&quot;
ControlToValidate=&quot;txtPassword&quot; ForeColor=&quot;#FF9900&quot; ValidationGroup=&quot;Login&quot;&amp;gt;*
&amp;lt;label for=&quot;PassLogin&quot; class=&quot;Hidden&quot;&amp;gt;
&amp;lt;/label&amp;gt;
&amp;lt;asp:TextBox ID=&quot;txtPassword&quot; TabIndex=&quot;1&quot; runat=&quot;server&quot; ForeColor=&quot;#96CDE0&quot;
TextMode=&quot;Password&quot;&amp;gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan=&quot;2&quot; align=&quot;left&quot;&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;td valign=&quot;top&quot; align=&quot;left&quot; class=&quot;fieldUserMessage email msg&quot;&gt;
&amp;lt;asp:Image runat=&quot;server&quot; ID=&quot;Image1&quot; ImageUrl=&quot;~/Images/information_icon_20.png&quot; /&amp;gt;
&lt;/td&gt;
&lt;td&gt;
&amp;lt;asp:LinkButton ID=&quot;lbtnForgotPassword&quot; runat=&quot;server&quot; Text=&quot;Forgot password&quot; TabIndex=&quot;1&quot;
Style=&quot;color: #99d4e8; font-weight: bold; text-decoration: underline; font-size: 10pt;&quot;
Font-Bold=&quot;True&quot;&amp;gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan=&quot;2&quot;&gt;
&lt;br /&gt;
&lt;/td&gt;
&lt;/tr&gt;
&amp;lt;%-- &lt;tr&gt;
&lt;td align=&quot;left&quot;&gt;
&amp;lt;asp:CheckBox ID=&quot;cbRememberMe&quot; runat=&quot;server&quot; Checked=&quot;true&quot; Text=&quot;Remember me&quot;
ForeColor=&quot;#41a5c6&quot; Font-Size=&quot;5pt&quot; TabIndex=&quot;1&quot; /&amp;gt;
&lt;/td&gt;
&lt;/tr&gt;--%&amp;gt;
&lt;tr&gt;
&lt;td colspan=&quot;2&quot;&gt;
&amp;lt;asp:ImageButton ID=&quot;btnLogin&quot; runat=&quot;server&quot; ImageUrl=&quot;~/Images/login_button.png&quot;
TabIndex=&quot;1&quot; BackColor=&quot;#214682&quot; ValidationGroup=&quot;Login&quot; OnClick=&quot;btnLogin_Click&quot; /&amp;gt;
&amp;lt;asp:ValidationSummary ID=&quot;ValidationSummary1&quot; runat=&quot;server&quot; BackColor=&quot;#3C6AAA&quot;
ShowMessageBox=&quot;True&quot; ShowSummary=&quot;False&quot; ValidationGroup=&quot;Login&quot; /&amp;gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</pre>
 

Answers (2)