我有一个表单,最初是通过jQuery隐藏的,当点击按钮时,两个单选按钮也会出现(初始状态下也通过jQuery隐藏)。当点击其中一个单选按钮时,用户将被重定向到另一个页面(这个功能很好用)。当点击另一个单选按钮时,“表单”将再次通过jQuery变为可见。
我的问题在于,当提交时服务器端验证“表单”中的字段,并重新加载带有验证错误消息的页面时,“表单”现在已经被隐藏了(如下面的初始jQuery所示)。
我该如何使表单在回发时可见? (我已经尝试过ASP面板和AJAX UpdatePanel,但都无济于事。)
** 这是我的jQuery代码: **
我的问题在于,当提交时服务器端验证“表单”中的字段,并重新加载带有验证错误消息的页面时,“表单”现在已经被隐藏了(如下面的初始jQuery所示)。
我该如何使表单在回发时可见? (我已经尝试过ASP面板和AJAX UpdatePanel,但都无济于事。)
** 这是我的jQuery代码: **
// Reveal Radio Fields
$(".btn-leavecomment, .txt-leavecomment").toggle(function(){
$("#commenttype").stop().animate({ down: "+=300" }, 3000)
$("#commenttype").stop().slideDown("slow");
}, function(){
$("#commenttype").stop().animate({ down: "-=300" }, 1400)
$("#commenttype").stop().slideUp("slow");
});
// Reveal Form on-click of one radio field in particular
$(".reveal_ccform").toggle(function(){
$("#ccform_container").stop().animate({ down: "+=300" }, 4000)
$("#ccform_container").stop().slideDown("slow:4000");
}, function(){
$("#ccform_container").stop().animate({ down: "-=300" }, 4000)
$("#ccform_container").stop().slideUp("slow:4000");
});
根据Moar的建议,新增了JavaScript实现,但仍然无法工作,有什么想法? :(
JavaScript:
<script type="text/javascript">
$(document).ready() {
function isPostBack()
{
if (!document.getElementById('clientSideIsPostBack'))
{
return false;
if (document.getElementById('clientSideIsPostBack').value == 'Y' )
return true;
}
// Reveal Comment Type
$(".btn-leavecomment, .txt-leavecomment").toggle(function () {
$("#commenttype").stop().animate({ down: "+=300" }, 3000)
$("#commenttype").stop().slideDown("slow");
}, function () {
$("#commenttype").stop().animate({ down: "-=300" }, 1400)
$("#commenttype").stop().slideUp("slow");
});
// Reveal Sign Guestbook Form
$(".reveal_ccform").toggle(function () {
$("#ccform_container").stop().animate({ down: "+=300" }, 4000)
$("#ccform_container").stop().slideDown("slow:4000");
}, function () {
$("#ccform_container").stop().animate({ down: "-=300" }, 4000)
$("#ccform_container").stop().slideUp("slow:4000");
});
// Hide 'Leave a Comment' button and 'Comment Type' div
$('.reveal_ccform').click(function () {
$(".btn-leavecomment").stop().fadeOut("slow:1500"),
$('#commenttype').slideUp("slow:8000");
});
}
}
</script>
C#:
if (Page.IsPostBack)
{
Page.ClientScript.RegisterStartupScript(GetType(), "IsPostBack", script, true);
//Second part of code will run if is postback = true
ClientScriptManager cs = Page.ClientScript;
Type csType = this.GetType();
cs.RegisterClientScriptBlock(csType, "openForms", "$(document).ready(openForms);", true);
}