问题
I want my div to visible on the basis of HiddenFiled
value. So I did the following:
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>
and CODE BEHIND
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 });
}
});
}
I am helpless to find the issue behind why alert(hf.value);
is not working, I guess
Sys.Application.add_load(BindEvents);
is not working, Anyone knows why its not working ?
Thanks.
来源:https://stackoverflow.com/questions/22190374/updatepanel-and-document-ready-sys-application-add-load-not-adding-handler