我希望我的div在HiddenFiled
值的基础上可见。所以我做了以下事情:
ASPX
<asp:UpdatePanel ID="up" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<script type="text/javascript">
Sys.Application.add_load(BindEvents);
</script>
<div id="addPopUp" runat="server" style="padding: 30px; height: auto; width: 450px;
overflow: hidden; display: none; background-color: White; border: 1px solid black;">
<table width="500px;">
<tr>
<td valign="top" align="left" style="width: 27%;">
<input type="hidden" runat="server" id="hfLevel" />
<input type="hidden" runat="server" id="hfLevel1Id" />
<input type="hidden" runat="server" id="hfLevel2Id" />
<input type="hidden" runat="server" id="hfLevel3Id" />
</td>
<td style="width: 80%;">
</td>
</tr>
<tr>
<td style="width: 20%;" align="left" class="topics">
</td>
<td style="width: 80%;">
<asp:RadioButton ID="radAdd" runat="server" AutoPostBack="true" GroupName="ModeAddEdit"
Text="Add Link" Checked="true" OnCheckedChanged="radAdd_CheckedChanged" />
<asp:RadioButton ID="radEdit" runat="server" AutoPostBack="true" GroupName="ModeAddEdit"
Text="Edit Link" OnCheckedChanged="radEdit_CheckedChanged" />
</td>
</tr>
<tr>
<td style="width: 20%;" align="left" class="topics">
<strong>Link Name :</strong>
</td>
<td style="width: 80%;">
<asp:TextBox ID="txtLinkName" CssClass="txtbox" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 20%;" class="topics">
<strong>Url :</strong>
</td>
<td style="width: 80%;">
<asp:TextBox ID="txtUrl" CssClass="txtbox" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 20%;" class="topics">
<strong>Position :</strong>
</td>
<td style="width: 80%;">
<asp:TextBox ID="txtPosition" CssClass="txtbox" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 20%;" class="topics">
<strong>Show on same page :</strong>
</td>
<td style="width: 80%;">
<asp:CheckBox ID="chkSamePage" runat="server" Checked="true" />
</td>
</tr>
<tr>
<td>
</td>
<td class="topics" align="left">
<asp:Button ID="btnSave" runat="server" Text="Save" CssClass="sfCustomButton" OnClick="btnSave_Click" />
<asp:Button ID="btnHide" runat="server" Text="Hide Link" CssClass="sfCustomButton" />
<input type="button" id="btnCancel" value="Cancel" class="sfCustomButton" onclick="hide()" />
</td>
</tr>
</table>
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="radAdd" />
<asp:AsyncPostBackTrigger ControlID="radEdit" />
<asp:PostBackTrigger ControlID="btnSave" />
<asp:PostBackTrigger ControlID="btnHide" />
</Triggers>
</asp:UpdatePanel>
和 代码背后
protected void radAdd_CheckedChanged(Object sender, EventArgs e)
{
hfShow.Value = "1";
}
protected void radEdit_CheckedChanged(Object sender, EventArgs e)
{
hfShow.Value = "1";
}
JAVASCRIPT
function BindEvents() {
$(document).ready(function () {
var hf = document.getElementById("hfShow"); alert(hf.value);
if (hf.value == "1") {
Popup.showModal('addPopUp', null, null, { 'screenColor': '#cccccc', 'screenOpacity': .6 });
}
});
}
我无法找到alert(hf.value);
无法正常工作的问题,我猜
Sys.Application.add_load(BindEvents);
无效,任何人都知道为什么它不起作用?
感谢。