AspTextbox没有响应 [英] AspTextbox Is Not Responding

查看:121
本文介绍了AspTextbox没有响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我是C#.NET技术的新手.

最近两天来,我遇到了一个问题.我的目标是,我要将asp文本框中的文本存储到MSSQL DB中.
(当页面重定向到其他页面时,或者当提到的asp文本框将其焦点移出时,我需要将文本保存在DB中)

为此,在asptxt_textchanged事件上,我将asp文本框的文本收集到字符串变量中,而在asptxt_onunload事件中,我将收集的变量发送到所需的存储过程.

但是,在向存储过程发送任何值之前,我无法将新插入/修改的文本收集到字符串变量中.它显示了一个旧值(已从数据库获取到特定asp文本框的值)

以下是我在页面加载时显示数据库内容的代码:

Hi folks,

I am a newbie in C#.NET technology.

I am facing a problem from last two days. My objective is that, I want to store the text from asp textbox into MSSQL DB.
(I need the text to be saved in DB when the page is redirected to some another page or when the mentioned asp text box will leave its focus)

To achieve this, on asptxt_textchanged event, I am collecting the text of asp textbox into a string variable and asptxt_onunload event I send the collected variable to required stored procedure.

But, before I sent any value to store procedure, I am not able to collect the new inserted/modified text into the string variable. It shows an old value (The value that has been fetched from DB to particular asp textbox)

Following is the code where I am displaying the contents from the DB on page load:

asptxt_TextRemarks.Text = mobj_DataSet.Tables[0].Rows[0][14].ToString();



以下是我要获取asptxt框的修改后文本的代码:



Following is the code where I want to fetch the modified text of the asptxt box:

protected void asptxt_TextRemarks_TextChanged(object sender, EventArgs e)
{
    mobj_bl_Company.Remarks = asptxt_TextRemarks.Text;
}



以下是我将值发送到存储过程的代码:



Following is the code from which I am sending the values to the stored procedure:

if (1 == mobj_dal_MainSystem.cls_Initialize(mstr_ConnectionString))
{
mobj_dal_CompanyList.updateRemarks(mobj_dal_MainSystem.getConnectionName(), mint_ClientId,      mint_CompanyId, str_RemarkContents, ref mstr_Exception);
}



问题是我无法接收更改后的



The problem is I am not able to receive the changed value of

asptxt_TextRemarks.Text;

值,因此我可以将其进一步分配给变量或数据库属性值.

请给我建议解决方案.非常感谢您的答复.
非常感谢您的答复.

问候,
G Nachiket.

so that I can further assign it to a variable or the DB property value.

Please suggest me the solution. I appreciate your answers in advance.
Thank you very much for your replies.

Regards,
G Nachiket.

推荐答案



将您的页面加载代码置于回发条件下,例如

Hi,

place your pageload code in postback condition like

  //under pageload
 if(!isPostBack)
{
  asptxt_TextRemarks.Text = mobj_DataSet.Tables[0].Rows[0][14].ToString();
}



最好的



All the Best


这篇关于AspTextbox没有响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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