c# textbox值的问题,弄不明白,求解答。分全给了

button的事件
if(TextBox2.Text!=null&&TextBox3.Text!=null)
{
try
{

luntan luntan = new luntan();
luntan.content = TextBox3.Text;
luntan.title = TextBox2.Text;
luntan.pId = TextBox1.Text;
luntan.dateOf = DateTime.Now.Date;
luntan.picAddress=picstr;
DataClassesDataContext dcdc = new DataClassesDataContext();
dcdc.luntan.InsertOnSubmit(luntan);
dcdc.SubmitChanges();

点击了确定以后

TextBox3.Text = null;
TextBox2.Text = null;
// TextBox1.Text = null;
Response.Redirect("Default4.aspx");
为什么if没起到限制作用,是因为textbox值不为空吗??解决办法是什么。

text默认空值为"",而不是null,本来你下个断点就很容易查出来的,改成
if(TextBox2.Text!="" && TextBox3.Text!="")
温馨提示:答案为网友推荐,仅供参考
相似回答