这是一个现有的Visual Studio 2003项目(用VB编写)。有一个输入表单,其中包含许多字段,包括due date
字段。此字段根据Reason type
下拉列表中选择的值进行populta,并且也可以编辑。最近,我不得不禁用due date
字段,以便无法更改填充值(基于登录用户)。我面临的问题是,当点击提交按钮时,IE弹出窗口打开,“截止日期”字段中的值只是消失并变为空白。
Private Sub btnSubmitOrdersTab_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmitOrdersTab.Click
If Not Me.txtPRCEmail.Value.Length = 0 Or Not hPRCEmail.Value.Length = 0 Then
SubmitClick()
Else
RegisterStartupScript("PRCEmail", "<script language=javascript>window.open (""" & CType(Application("cBaseURL"), String) & "administration/supervisors/Orders/prc_email_reason.aspx"",null,""height=200,width=400,status=yes,toolbar=no,menubar=no,location=no"");</script>")
End If
End Sub
我尝试使用due date
在RegisterStartupScript()
函数之前获取duedatevalue = Me.txtDueDate.Value
的值,但它是空白的。
有什么办法可以阻止due date
字段变成空白。如果未禁用due date
字段,则不会出现此问题。
这是我在onload
的{{1}}事件中调用的Java脚本函数,用于禁用截止日期。
<body>
我使用disable的原因是因为截止日期是function DisableDueDate()
{
if (udisable == "true")
document.getElementById("divduedate").setAttribute('disabled',true);
else
document.getElementById("divduedate").setAttribute('disabled',false);
}
标签以及旁边的gif(不是服务器控件),点击时会弹出日历,以便用户可以选择日期。我希望禁用<td>
标记的全部内容 - 包括gif。
答案 0 :(得分:0)
如果您想要读取服务器端texbox的值,请使用 readonly 而不是使用禁用文本框。
document.getElementById("divduedate").setAttribute('readonly',true);
OR
document.getElementById("divduedate").readOnly=true
OR
使用jQuery:
$('#readonly').attr("readonly", true)
已禁用的属性不允许“divduedate”将其值发布到服务器。
答案 1 :(得分:0)
在btnSubmitOrdersTab_Click
事件中,您可以将due date
的值保存在Session
中,然后在Page_Load
中,您可以从{{1}获取值用它设置Session
字段。
答案 2 :(得分:0)
不要将Enabled
属性设置为False。而是使用ReadOnly
属性并将其设置为true。