文字在页面加载时消失 [英] Text disappears on page load

查看:76
本文介绍了文字在页面加载时消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我有一个asp.net Web应用程序.在那我有一个表单,在我有的表单中

1.)4个文本框
2.)两个组合框
3.)四个按钮


我在第一个文本框中输入了文本,然后从这两个组合框中选择了该项.现在有另一个文本框和

在其前面名为添加"的按钮.在该文本框中输入文本后单击添加时,
中的整个条目
失踪.实际上,我有一个主按钮名称为save ..我想保存所有信息,但在该页面之前

加载,所有信息都消失了.

页面加载时如何保存文本..我从过去16天开始苦苦挣扎,但仍未找到解决方法...
这是我的页面加载,所有控件的所有Enableviewstate均为true

Hello to all,
I have an asp.net web application.In that i have a form,In the form I have

1.) 4 Text box
2.) two combo box
3.) Four buttons


I entered the text in first text box and select the item from those two combobox. Now there is another textbox and a

button named as add in front of it. When clicks on add after entering the text in that text box, the whole entry from the

form disaapears. Actually I have a main button names as save..I wants to save all the information but before that page

loads and all the information become disappears.

How could i hold the text when page load..I am struggling from last 16 days,yet not get the solution...
This is my page load and all Enableviewstate is true for all controls

protected void Page_Load(object sender, EventArgs e)
{
//page load
if (!Page.IsPostBack)
{
//if (Request.QueryString["id"] != null)
//{

//}
//else if (Request.QueryString["id"] == null)
//{
//btnSubmitAll.Visible = true;
//laberror.Visible = false;
//btnUpdate.Visible = false;
//btnUpdatePro.Visible = false;
//btnUpdateRef.Visible = false;
//btnUpdateStatus.Visible = false;

ds1 = con.ExecuteSPDS("TypeOfDll", "0", "ddlDailyReport");
if (ds1.Tables.Count > 0)
{
if (ds1.Tables[1].Rows.Count > 0)
{
ddlProduct.DataSource = ds1.Tables[1];
ddlProduct.DataTextField = "ProductName";
ddlProduct.DataValueField = "Id";
ddlProduct.DataBind();
ddlProduct.SelectedValue = "0";
}

if (ds1.Tables[0].Rows.Count > 0)
{
ddlHOffState.DataSource = ds1.Tables[0];
ddlHOffState.DataTextField = "State";
ddlHOffState.DataValueField = "Id";
ddlHOffState.DataBind();
ddlHOffState.SelectedValue = "0";
}

if (ds1.Tables[2].Rows.Count > 0)
{
ddlref.DataSource = ds1.Tables[2];
ddlref.DataTextField = "Reference";
ddlref.DataValueField = "Id";
ddlref.DataBind();
ddlref.SelectedValue = "0";
}

if (ds1.Tables[3].Rows.Count > 0)
{
ddlstatus.DataSource = ds1.Tables[3];
ddlstatus.DataTextField = "SalesStatus";
ddlstatus.DataValueField = "Id";
ddlstatus.DataBind();
ddlstatus.SelectedValue = "0";
}

if (ds1.Tables[4].Rows.Count > 0)
{
ddlOffType.DataSource = ds1.Tables[4];
ddlOffType.DataTextField = "OffType";
ddlOffType.DataValueField = "Id";
ddlOffType.DataBind();
ddlOffType.SelectedValue = "0";
}
//}

//fill ds for grids//
}

}
if (Request.QueryString["id"] != null)
{
Filleditgrid();
}
else if (Request.QueryString["id"] == null)
{
FillDs();
}


// btnUpdOffContact.Visible = false;

}


从答案移出代码块[/编辑]
请帮助我


code block moved from answer[/Edit]
Plz help me

推荐答案

在该文本框中输入文本后单击添加时,表单中的整个条目就会消失
听起来像发生了回发,但一切都消失了.重置为旧值.

您已禁用页面或控件的视图状态,或者正在重置页面加载中的控件值.
继续阅读:了解ASP.NET视图状态 [ ASP.NET页面生命周期 [ ^ ],并了解如何使用 Visual Studio调试器 [使用调试器 [
When clicks on add after entering the text in that text box , the whole entry from the form disaapears
Sounds like a postback happened and all gone. Reset to old values.

Either, you have disabled viewstate for the page or controls or you are resetting the control values in your pageload.
Read on: Understanding ASP.NET View State[^]

But, before moving any forward, you need to read on ASP.NET Page Lifecycle[^] and learn on how to use Visual Studio DEBUGGER[^].
This also: Using the DEBUGGER[^]


这篇关于文字在页面加载时消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆