我似乎可以弄清楚如何用SweetAlert的提示替换默认的JS提示,并使用OnClientClick =“ HiddenField1.value”将提示返回的值分配给一个隐藏的字段,就像我当前正在做的那样(在下面的代码中) = defaultval()“
<script language='javascript'>
function defaultval() {
var pmt = prompt('Please enter a name for the template.',
document.getElementById('HiddenFieldCurrentTemplate').value);
return pmt;
}
</script>
<asp:Button ID="btnSaveTemplate" runat="server" CssClass="btn-primary" OnClientClick="HiddenField1.value = defaultval()" Text="Save as Template" />
答案 0 :(得分:0)
在此处的SweetAlert文档中进行了修改:
https://sweetalert.js.org/guides/#using-dom-nodes-as-content
swal("Please enter a name for the template.", {
content: "input",
})
.then((response) => {
document.getElementById('HiddenFieldCurrentTemplate').value = response;
});