控制相关问题(Control related issue)

   IT问题网   2020-06-26 00:00:00

问 题

尊敬的先生,



我有一个页面,其中我得到错误"名称txtbox在当前上下文中不存在"。这意味着所有控件都给出错误。

aspx和aspx.cs文件是 -

 使用系统; 
使用 system.data;
使用 system.configuration;
使用 system.collections;
使用 system.web;
使用 system.web.security;
使用 system.web.ui;
使用 system.web.ui.webcontrols;
使用 system.web.ui.webcontrols.webparts;
使用 system.web.ui.htmlcontrols;
使用 system.web.mail;
使用 richclass;

public partial class control_userdownloads:system.web.ui.usercontrol
{
adddownload ad = new adddownload();
受保护 void page_load( object sender,eventargs e)
{
if (!ispostback)
{
addnews adn = new addnews();
table3.visible = true ;
dldown.visible = false ;
binddownload();
// if(request.querystring ["uname"]!= null)
// {
// if(session ["uname"]。tostring()=="0")
/ / {
// object obj = richclass.security.decryptdata(request.querystring ["uname"]);
// bool chk = adn.seluserfirsttime(obj.tostring());
// if(chk == true)
// {
// dldown.visible = true;
// table3.visible = false;
// 会话["uname"] = textbox1.text;
// }
// else
// {
// showmessage ("电子邮件id不匹配!请输入以下所需信息。");
// }
// }
// }
}
if (会话[" 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()== " "
{
返回 false ;
}
其他
{
返回 ;
}
}
void binddownload()
{
dataset ds;
ds = ad.selectallcourse();
if (ds.tables [ 0 ]。rows.count gt; 0
{
dldown.datasource = ds;
dldown.databind();
}
else
{
dldown.visible = false ;
}
}
受保护 void dldown_itemdatabound( object sender,datalistitemeventargs e)
{
if (e.item.itemtype == listitemtype。 item || e.item.itemtype == listitemtype.alternatingitem)
{
// dataset d = ad.selectallcourse();
// string not = d.tables [0 ] .rows [0] ["nt"]。tostring();
// if(not =="")
// {
// ((标签)e.item.findcontrol("lblnt"))。visible = false;
// }
// else
// {
// ((label)e.item.findcontrol("lblnt"))。visible = true;
// }
}
}
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(" 恭喜!现在您可以下载可用的信息!");
dldown.visible = true ;
table3.visible = false ;
会话[" uname"] = txtemail.text.trim();
showmessage(" 恭喜!现在您可以下载信息。请查看您的电子邮件!");
string uname = richclass.security.encryptdata(txtemail.text.trim());
string url = " http:// www.shridharuniversity.ac.in/download.aspxuname =" + uname + " ";
sendmail();
usermail(url);
clrall();
}
else
{
showmessage(" 您的电子邮件id已存在!");
}
}
其他
{
showmessage( " 请检查至少一个感兴趣的学位!");
}
}
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 = " ";
}
受保护 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 ;
会话[" uname"] = textbox1.text;
}
else
{
showmessage(" 电子邮件id不匹配!请输入以下所需信息。");
}

}
受保护 void lnklogin_click( object sender,eventargs e)
{
}
protected void linkbutton1_click( object sender,eventargs e)
{
response.redirect(" test.aspx");
}
public void sendmail()
{
string message = " lt; tablegt;lt; trgt; ;lt; tdgt;名称:lt; / tdgt;lt; tdgt;" + txtname.text + " lt; / tdgt;lt; / trgt;lt; trgt;lt; tdgt;出生日期:lt; / tdgt;lt; tdgt;" + txtsdt.text + " lt; / tdgt;lt; / trgt;lt; trgt;lt; tdgt;父亲姓名:lt; / tdgt;lt; tdgt;" + txtfname.text + " lt; / tdgt;lt; / trgt;lt; trgt;lt; tdgt;电子邮件:lt; / tdgt;lt; tdgt;" + txtemail.text + " lt; / tdgt;lt; / trgt;lt; trgt;lt; tdgt;电话号码:lt; / tdgt;lt; tdgt;" + txtphone.text + " lt; / tdgt;lt; / trgt;lt; trgt;lt; tdgt;移动设备:lt; / tdgt;lt; tdgt;" + txtmobile + " lt; / tdgt;lt; ; / trgt;lt; trgt; lt; tdgt;城市:其中; / tdgt;lt; tdgt; " + txtcity.text + " lt; / tdgt;lt; / trgt; lt; trgt;lt; tdgt;对lt; / tdgt;感兴趣的学位lt; tdgt;" + degree()。tostring()+ " lt; / tdgt;lt; / trgt;lt; / tablegt;";

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");
// dim objmail as new mailmessage
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;
尝试
{
smtpmail.smtpserver = " mail.webshree.com";
smtpmail.send(objmail);
}
catch (例外情况)
{
// smtpmail.send(objmail);
}
}

public void usermail( string url)
{
string message = " lt; table border = 0 cellpadding = 0 cellspacing = 0gt;lt; trgt;lt; tdgt;亲爱的" + txtname.text + " , lt; / tdgt;lt; / trgt;lt; trgt;lt; tdgt;欢迎来到shridhar大学,下载信息请点击以下链接:lt; / tdgt;lt; / trgt;lt; trgt;lt; tdgt;" + url + " lt; / tdgt;lt; / trgt;lt; / tablegt;";

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");
// dim objmail as new mailmessage
objmail.to = txtemail.text 。修剪();
objmail.bcc = " webshri@gmail.com";
objmail.from = " info@shridharuniversity.ac.in";
objmail.subject = " new candidate @ download section";
objmail.bodyformat = mailformat.html;
objmail.body = message;
尝试
{
smtpmail.smtpserver = " mail.webshree.com";
smtpmail.send(objmail);
}
catch (例外情况)
{
// smtpmail.send(objmail);
}
}


}






.aspx文件是 -

 lt;%@    控制   语言  ="  c#"    autoeventwireup   ="  true"    codefile   ="  userdownloads.ascx.cs"   继承  ="  control_userdownloads"   %gt;  
lt;%@ 注册 程序集 =" ajaxcontroltoolkit" 命名空间 =" ajaxcontroltoolkit" tagprefix =" cc1" %gt;

lt; table border =" 0" cellpadding =" 0" cellspacing =" 0" width =" 470" id =" table3" runat =" server" gt;
lt; tr gt;
lt; td align =" center" gt;
lt; h3 gt; 如果您已输入以下信息,请仅输入您的电子邮件。lt; / h3 gt; lt; / td gt;
lt; / tr gt;
lt; tr gt;
lt; td gt;
lt; table id =" table2" runat =" server" border =" 0" cellpadding =" 0" cellspacing =" 0" class =" feedbackfrm" width =" 100%" gt;
lt; tr gt;
lt; td width =" 150px" gt;
电子邮件*:lt; / td gt;
lt; td gt;
lt; asp:textbox id =" textbox1" runat =" server" gt; lt; br / gt; lt; asp:requiredfieldvalidator

id =" requiredfieldvalidator7" runat =" server" controltovalidate =" textbox1" 显示 = " 动态"

errormessage =" 需要电子邮件!" validationgroup =" sss" gt; lt; asp:regularexpressionvalidator

id=\" regularexpressionvalidator7\" runat=\"server\" controltovalidate=\"textbox1\"

display=\"dynamic\" errormessage=\"invalid email!\" validationexpression=\"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*\"

validationgroup=\"sss\"gt;lt;/tdgt;
lt;/trgt;
lt;trgt;
lt;tdgt;
lt;/tdgt;
lt;tdgt;
lt;asp:button id=\"button1\" cssclass=\"btn\" runat=\"server\" text=\"submit\" onclick=\"button1_click\" validationgroup=\"sss\" /gt;lt;/tdgt;
lt;/trgt;

lt;table width=\"100%\" id=\"table1\" runat=\"server\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"feedbackfrm\"gt;
lt;trgt;
lt;td width=\"150px\"gt;
name*:lt;/tdgt;
lt;tdgt;
lt;asp:textbox id=\"txtname\" runat=\"server\"gt;lt;br /gt;lt;asp:requiredfieldvalidator

id=\"requiredfieldvalidator1\" runat=\"server\" controltovalidate=\"txtname\" display=\"dynamic\"

errormessage=\"name required!\" validationgroup=\"vldgrp\"gt;lt;asp:regularexpressionvalidator

id=\"regularexpressionvalidator1\" runat=\"server\" controltovalidate=\"txtname\" display=\"dynamic\"

errormessage=\"invalid name!\" validationexpression=\"^[^lt;gt;%\/@#$]{3,50}$\" validationgroup=\"vldgrp\"gt;lt;/tdgt;
lt;/trgt;
lt;trgt;
lt;tdgt;

date of birth*:lt;/tdgt;
lt;tdgt;
lt;asp:textbox id=\"txtsdt\" runat=\"server\"gt;lt;br /gt;
lt;cc1:calendarextender id=\"calendarextender1\" runat=\"server\" format=\"d/m/yyyy\" targetcontrolid=\"txtsdt\"gt;
lt;asp:requiredfieldvalidator id=\"requiredfieldvalidator6\" runat=\"server\" controltovalidate=\"txtsdt\"

display=\"dynamic\" errormessage=\"date of birth required!\" validationgroup=\"vldgrp\"gt;
lt;asp:regularexpressionvalidator id=\"regularexpressionvalidator6\" runat=\"server\" controltovalidate=\"txtsdt\"

display=\"dynamic\" error message=\"date of birth!\" validationexpression=\"^[^lt;gt;%\@#$]{3,50}$\"

validationgroup=\"vldgrp\"gt;lt;/tdgt;
lt;/trgt;
lt;trgt;
lt;tdgt;

father's name*:lt;/tdgt;
lt;tdgt;
lt;asp:textbox id=\"txtfname\" runat=\"server\"gt;lt;br /gt;lt;asp:requiredfieldvalidator

id=\"requiredfieldvalidator2\" runat=\"server\" controltovalidate=\"txtfname\" display=\"dynamic\"

errormessage=\"father's name required!\" validationgroup=\"vldgrp\"gt;lt;asp:regularexpressionvalidator

id=\"regularexpressionvalidator2\" runat=\"server\" controltovalidate=\"txtfname\"

display=\"dynamic\" errormessage=\"invalid father's name !\" validationexpression=\"^[^lt;gt;%\/@#$]{3,50}$\"

validationgroup=\"vldgrp\"gt;lt;/tdgt;
lt;/trgt;
lt;trgt;
lt;tdgt;

e-mail*:lt;/tdgt;
lt;tdgt;
lt;asp:textbox id=\"txtemail\" runat=\"server\"gt;lt;br /gt;lt;asp:requiredfieldvalidator

id=\"requiredfieldvalidator3\" runat=\"server\" controltovalidate=\"txtemail\" display=\"dynamic\"

errormessage=\"
email required!\" validationgroup=\"vldgrp\"gt;lt;asp:regularexpressionvalidator

id=\"regularexpressionvalidator3\" runat=\"server\" controltoval idate=\"txtemail\"

display=\"dynamic\" errormessage=\"invalid email!\" validationexpression=\"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*\"

validationgroup=\"vldgrp\"gt;lt;/tdgt;
lt;/trgt;
lt;trgt;
lt;tdgt;
phone no*:lt;/tdgt;
lt;tdgt;
lt;asp:textbox id=\"txtphone\" runat=\"server\"gt;lt;br /gt;lt;asp:regularexpressionvalidator

id=\"regularexpressionvalidator9\" runat=\"server\" controltovalidate=\"txtphone\"

display=\"dynamic\" errormessage=\"invalid phone\" validationexpression=\"^[0-9-]{6,100}$\"

validationgroup=\"vldgrp\"gt;
lt;asp:requiredfieldvalidator id=\"requiredfieldvalidator14\" runat=\"server\" controltovalidate =\"txtphone\"

display=\"dynamic\" errormessage=\"enter phone!\" validationgroup=\"vldgrp\"gt;
lt;/tdgt;
lt;/trgt;
lt;trgt;
lt;tdgt;

mobile*:lt;/tdgt;
lt;tdgt;
lt;asp:textbox id=\"txtmobile\" runat=\"server\"gt;lt;br /gt;lt;asp:regularexpressionvalidator

id=\"regularexpressionvalidator4\" runat=\"server\" controltovalidate=\"txtmobile\"

display=\"dynamic\" errormessage=\"invalid mobile\" validationexpression=\"^[0-9-]{10,100}$\"

validationgroup=\"vldgrp\"gt;
lt;asp:requiredfieldvalidator id=\"requiredfieldvalidator4\" runat=\"server\" controltovalidate=\"txtmobile\"

display=\"dynamic\" errormessage=\"enter mobile!\" validationgroup=\"vldgrp\"gt;lt;/tdgt;
lt;/trgt;
lt;trgt;
lt;tdgt;

city*:lt;/tdgt;
lt;tdgt;
lt;asp:textbox id=\"txtcity\" runat=\"server\"gt;lt;br /gt;lt;asp:requiredfieldvalidator

id=\"requiredfieldvalidator5\" runat=\"server\" controltovalidate=\"txtcity\" display=\"dynamic\"

errormessage=\"city required!\" validationgroup=\"vldgrp\"gt;lt;asp:regularexpressionvalidator

id=\"regularexpressionvalidator5\" runat=\"server\" controltovalidate=\"txtcity\" display=\"dynamic\"

errormessage=\"invalid city!\" validationexpression=\"^[^lt;gt;%\/@#$]{3,50}$\" validationgroup=\"vldgrp\"gt;lt;/tdgt;
lt;/trgt;
lt;trgt;
lt;td valign=\"top\"gt;
degree interested in*lt;/tdgt;
lt;td valign=\"top\"gt;
lt;asp:checkboxlist id=\"checkboxlist1\" runat=\"server\" repeatcolumns=\"5\"gt;
lt;asp:listitemgt;diploma
lt;asp:listitemgt;ug
lt;asp:listitemgt;pg
lt;asp:listitemgt;research
lt;asp:listitemgt;certificate
lt;/tdgt;
lt;/trgt;
lt;trgt;
lt;tdgt;
lt;/tdgt;
lt;tdgt;
lt;asp:button id=\"btnsubmit\" runat=\"server\" cssclass=\"btn\" text=\"submit\" onclick =\"btnsubmit_click\" validationgroup=\"vldgrp\" /gt;lt;/tdgt;
lt;/trgt;
lt;trgt;
lt;tdgt;
lt;/tdgt;
lt;tdgt;
lt;/tdgt;
lt;/trgt;

lt;/tdgt;
lt;/trgt;
lt;trgt;
lt;tdgt;

lt;/tdgt;
lt;/trgt;


lt;asp:datalist id=\"dldown\" runat=\"server\" repeatcolumns=\"1\" onitemdatabound=\"dldown_item databound\" cssclass=\"dwnld\"gt;lt;itemtemplategt;
lt;h3gt; lt;asp:hyperlink id=\"hyp\" runat=\"server\" text='lt;%# eval(\"hd\") %gt;' navigateurl='lt;%# \"~/downloads/\"+eval(\"fname\") %gt;' target=\"_blank\"gt;lt;/h3gt;
lt;p class=\"note\" runat=\"server\" id=\"noteid\" visible='lt;%# getnote(eval(\"nt\")) %gt;'gt;
lt;asp:label id=\"lblnt\" runat=\"server\" text='lt;%# \"note: \" + eval(\"nt\")%gt;' visible='lt;%# getnote(eval(\"nt\")) % gt;'gt;
lt;/itemtemplategt;

lt;asp:updatepanel id=\"updatepanel1\" runat=\"server\"gt;




i am getting error while controls are on .aspx.





pls help me out.



thanks

abhishek

解决方案

{3,50}

\" validat iongroup=\"vldgrp\"gt;lt;/tdgt;
lt;/trgt;
lt;trgt;
lt;tdgt;

date of birth*:lt;/tdgt;
lt;tdgt;
lt;asp:textbox id=\"txtsdt\" runat=\"server\"gt;lt;br /gt;
lt;cc1:calendarextender id=\"calendarextender1\" runat=\"server\" format=\"d/m/yyyy\" targetcontrolid=\"txtsdt\"gt;
lt;asp:requiredfieldvalidator id=\"requiredfieldvalidator6\" runat=\"server\" controltovalidate=\"txtsdt\"

display=\"dynamic\" errormessage=\"date of birth required!\" validationgroup=\"vldgrp\"gt;
lt;asp:regularexpressionvalidator id=\"regularexpressionvalidator6\" runat=\"server\" controltovalidate=\"txtsdt\"

display=\"dynamic\" errormessage=\"date of birth!\" validationexpression=\"^[^lt;gt;%\@#
{3,50}

标签:控制节制相关相干问题



分享:

  • 微信
  • QQ好友
  • QQ空间
  • 新浪微博


热门推荐

在运行时动态绘制div(draw div dynamically at runtime)

problem hiii all, i have a page which i draw all its attr ...

转换数据库值(Convert a databse value)

problem i have a table one field is price and ...

如何使单元格的内容可见为false(How do i make the content of a cell visible false)

problem how do i make the content of a cell visible false ...

qtwebkit并连接cpp和javascript(qtwebkit and connect cpp and javascript)

problem hi to all i am using qwebkit i have a cpp object ...

response.flush&到Response.End(problem with response.flush & response.end)

problem hello everybody, i have used response.flush() wi ...

ShellExecute()不执行(ShellExecute() Not Executing)

problem i''m running a batch file from c++ code.when i ru ...

Radion Button使用Javascript隐藏/可见(Radion Button Hide/Visible Using Javascript)

problem i want hide/visible radio button using javascript ...

如何在此xml文件中插入/删除节点(how to insert/delete a node to this xml file)

problem hi all :) i search in webto find a code that ins ...

XML + DTD,不会出现在浏览器中(XML + DTD, won't show up in browser)

problem my code looks right, validates, but when i open i ...

什么是样品反射(What is Reflection with sample)

problem hi everybody, could u plz tell me reflection d ...

在封闭网络上获取设备的IP地址(optaining IP addresses of devices on a closed network)

problem i have a situation where i have multiple devices ...

如何限制用户在asp.net中通过javascript在TextBox中仅输入alphabates(How to Restrict user to enter only alphabates in TextBox by javascript in asp.net)

problem how to restrict user to enter onlyalphabates in t ...

如何在远程服务器上使用jquery调用webservice?(how to call webservice using jquery on remote server)

problem i have created one html page,in that using jquery ...

pchealth文件夹占用了大量空间(pchealth folder consuming a lot of space)

problem in my server there are plenty of cab ...

如何在vb.net网站中添加c#名称空间?(How can add c# namespace in a vb.net Website)

problem hello codian, i want to create two namespaces in ...

仅搜索已更改的目录(Search Only Changed Directory(s))

problem i''m running this batch that works pr ...

在VB2010服务中打开Word文档(Opening Word document in a VB2010 service)

problem hi there, i try to open a word docum ...

VB.Net窗口服务安装64位(VB.Net window service install 64 bit)

problem i''m writing a windows service in vs 2010 and usi ...

光标位置相对左下角?(cursor position relative lower left corner )

problem in my project change cursor shape only in mypanel ...

发送和接收短信(send and recive sms)

problem hi all i want a program to send and recieve sms a ...