简体   繁体   English

在表单提交时更新文本输入中的值-asp.net

[英]Update values in text input on form submission - asp.net

I started learning asp.net to make a very simple web app which can manage the scheduled tasks of the machine where it runs. 我开始学习asp.net,以制作一个非常简单的Web应用程序,可以管理运行该计算机的计划任务。 I have created a very simple form in the .aspx file: 我在.aspx文件中创建了一个非常简单的表单:

<form id="form1" runat="server" OnClick="Form_Submit">
    <p>
        <input class="form-control" id="scheduleName"  type="Text" runat="server"  />
    </p>
    <p>
        <input class="form-control" id="checkschedule"  type="Text" runat="server"  />
    </p>
    <p>
        <input class="btn btn-default" value="Save" type="Submit" runat="server"  />
    </p>
</form>

I then have the following code on the corresponding .cs file 然后,在相应的.cs文件上有以下代码

public partial class Content : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }

    public void Form_Submit(object sender, EventArgs e)
    {
        string test = scheduleName.Value;
        checkschedule.Value = test;
    }
}

I tested I can populate the inputs from the onload function (I will use it to show the list of schedules on the system) But I cannot get to modify the value of checkschedule when I post the form from the browser - It doesn't change on my browser. 我测试了我可以填充onload函数的输入(我将使用它显示系统上的日程表列表),但是当我从浏览器中发布表单时,我无法修改checkchedule的值-它不会改变在我的浏览器上。

I guess I should notify that I've changed the value and send it back... but I cannot find a proper way to do it. 我想我应该通知我已经更改了值并将其发送回去……但是我找不到正确的方法来实现它。 Checked other answers but couldn't get my head around this.. any help is appreciated! 检查了其他答案,但无法解决这个问题..任何帮助,感激不尽!

我自己使用会话保存的变量解决了这个问题(实际上是做我想做的更好的方法)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM