问题描述
在 asp.net webform 中,字段是在运行时根据 page_init 上的属性创建的,具有初始值。例如,2 个文本框是基于属性创建的。用户使用数字更改第一个文本框值并单击提交按钮。具有所有属性的实体创建并传输到服务器,计算第二个属性的值并回发页面。再次在 page_init 中重建字段并将值放入其中,第二个字段由新创建。但是在 page_load 中,初始值放在第二个字段中,这是计算性的,同样的值显示给用户。
private void Page_Init(object sender,EventArgs e)
{
CreateProperties(entity);
}
private void CreateProperties(Entity en)
{
foreach(PropModel prop in en.PropList)
{
CreateProp(prop);
}
}
private void CreateProp(PropModel property)
{
switch (property.displayType)
{
case Gp_PropertydisplayType.Number:
createdControl = FillTextBoxField(property);
...
}
this.Controls.add(createdControl );
}
private Control FillTextBoxField(PropModel property)
{
UcTextBox rtx = LoadControl("/UcTextBox.ascx") as UcTextBox;
rtx.ID = GetPropertyControlId(property);
string value = property.CurrentValue as string;
rtx.Value = value;
return rtx;
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)