我有一个按钮,我需要一个确认弹出窗口。
这就像是用户单击是或否的协议。
白色面板中有数据,下面有两个按钮。
数据很大,所以我需要数据所在的面板中的滚动条。
这在winform应用程序中非常容易,但现在我正在使用Web应用程序。 我通常使用javascript或Ajax来显示弹出窗口确认..
这是AJAX中的代码:
<p style="background-color: #D0D8E8; text-align: right; padding-right: 20px;">
<asp:Button class="buttonStyle" ID="Update1" runat="server" Text="Update"
onclick="Update1_Click" CausesValidation="true" />
<cc1:ConfirmButtonExtender ID="Update1_ConfirmButtonExtender" runat="server"
ConfirmText="Are you sure you want to make changes in config file? Please restart 'Copiun Backup Server' service for changes to take effect."
Enabled="True" TargetControlID="Update1">
</cc1:ConfirmButtonExtender>
</p>
这就是我在javascript中所做的:
<script type="text/javascript">
function OnConfirm() {
if (confirm("Are you sure you want to reset?")) {
return true;
} else {
return false;
}
}
请帮助..谢谢
答案 0 :(得分:1)
来自here:
设置焦点可能会将其滚动到视图中(未测试),在if:
之前将其添加到js中document.getElementById('fieldId').focus()
该页面上的其他内容很酷:
“这会将光标发送到未完成的字段并将字段变为粉红色。”
if (document.yourform.fieldname.value == "") {
alert("You have not filledin this field.");
document.yourform.fieldname.focus();
if(document.all || document.getElementByID){
document.yourform.fieldname.style.background = "pink";
}
return false;
}
答案 1 :(得分:1)
您最好创建自己的确认对话框。使用标准确认对话框看起来非常难看,有很多数据,甚至滚动条更加丑陋。您可以使用AJAX Toolkit附带的模态poup对话框,也可以使用jQuery UI对话框。
以下是jQuery UI对话框的链接: