通过循环更新文本框的text属性 [英] update the textbox text property through loop

查看:81
本文介绍了通过循环更新文本框的text属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好:

我想从循环内更新Asp.Net中我的文本框控件的文本属性.我尝试将Ajax updatepanel与计时器控件一起使用,但无法更新文本属性.上周以来一直在搜索此文件,但找不到任何回答任何帮助将不胜感激:( :( :(

谢谢.

OP中的代码,已从答案中删除.
谢谢大家的答复.这是我的代码.这是我在代码中的按钮单击事件,您可以看到我正在更新

Hello There:

I want to update the text property of my textbox control in Asp.Net from within loop.I have tried using Ajax updatepanel with the timer control but unable to update the text property.I have been searching this since last week but unable to find any answer any help would be higly appreciated :( :( :(

Thanks.

Code from OP, removed from answers.
Thanks all of you for the reply. Here is my code.This is my button click event in this code you can see I am updating the

TxtContent.Text


在循环中,文本由用户定义的函数
返回


within a loop the text is being returned by a user defined function called

ReturnBodyText()


之后,我将文本分配给viewstate,以便在计时器滴答事件中,我可以调用文本并更新文本框的text属性,然后在计时器滴答事件中,将viewstate值分配给文本框.


afterwards I am assigning the text to the viewstate so that at the timer tick event I can recall the text and update the textbox text property and then at the timer tick event assigning the viewstate values to the textbox.

protected void Button4_Click(object sender, EventArgs e)
{
    ArrayList FilePath = (ArrayList)ViewState["ArrayList"];
    int i = 0;
    int b = 1;
    foreach(string[] sr in FilePath)
    {
        string Month = sr[i];
        string datewithzero;
        datewithzero = String.Format("{0:00}", b);
        string[] FilesArray = (string[])listfiles(Month, datewithzero).ToArray(typeof(string));
 
        foreach (string FileNameWithExtension in FilesArray)
        {
            ListBox4.Items.Add(FileNameWithExtension);
            TxtContent.Text = ReturnBodyText(Month, datewithzero, FileNameWithExtension);
            ViewState["Content"] = TxtContent.Text;
            Timer1.Enabled = true;
            Timer1_Tick(ViewState["Content"], e);
        }
        i = i + 1;
        b = b + 1;
    }
}

protected void Timer1_Tick(object sender, EventArgs e)
{
    TxtContent.Text =(string) ViewState["Content"];
    TxtContent.DataBind();
}




希望以上描述能帮助您理解我的问题

谢谢. :)
[/Edit]




I Hope the above description will help you guys in understanding my problem

Thanks.Smile | :)
[/Edit]

推荐答案

尝试一下...
Try This..
 <form id="form1"  runat="server">
 <asp:ScriptManager ID="ScriptManager1" runat="server">
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
        <contenttemplate>
          <asp:TextBox ID="txtChangeValue" runat="server">
        </contenttemplate>
    
 <asp:Timer ID="Timer1" runat="server" Interval="500" ontick="Timer1_Tick">
 
</form>


在代码中


In Code

static int count = 0;
   protected void Timer1_Tick(object sender, EventArgs e)
   {
       txtChangeValue.Text = count.ToString();
       count += 1;
   }


与我们显示一些时钟或递增计数器相同.
尝试使用像Always Visible Control Extender这样的Ajax控件工具包的控件.
Its same as we display some clock or incrementing counter.
Try to use Ajax control toolkit''s control like Always Visible Control Extender.


在ASP.Net设计中使用更新面板
Use update panel in ASP.Net design


这篇关于通过循环更新文本框的text属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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