ScriptManager不使用自定义警报 [英] ScriptManager not working with custom alerts
问题描述
您好CodeProject,
我正在尝试使用 SweetAlert [ ^ ]并使用scriptmanager显示sweetalert警报消息。
这是我的代码。
Hi CodeProject,
I am trying to use SweetAlert[^] in my project and using scriptmanager to show the sweetalert alert messages.
Here is my code.
<script type="text/javascript">
function Showalert() {
swal("Good job!", "You clicked the button!", "success");
return true;
}
</script>
我的函数我称之为
my function where I am calling it
Private Sub test()
ScriptManager.RegisterStartupScript(Me, [GetType](), "displayalertmessage", "Showalert();", True)
End Sub
和按钮后面的代码我打电话给它
and the code behind the button I am calling it from
Protected Sub btnSendM_Click(sender As Object, e As EventArgs) Handles btnSendM.Click
If txtName.Text = "Enter Name" Or txtName.Text = "" Or _
txtEmail.Text = "Enter Email" Or txtEmail.Text = "" Or _
txtPhone.Text = "Enter Phone Number" Or txtPhone.Text = "" Or _
txtMessage.Text = "Enter Your Message." Or txtMessage.Text = "" Then
'btnHidden_Click(sender, e)
test()
Else
contactClass.sendMessage(txtName.Text, txtEmail.Text, txtPhone.Text, txtMessage.Text)
'Button1_Click(sender, e)
End If
End Sub
问题是如果我将Showalert()函数中的swal更改为简单警报它可以工作但是swal不行,我也是把SweetAlert css和js带到了可以工作的页面,如果我输入这段代码
The problem is if I change the swal in the Showalert() function to simple alert it works but swal dont works, I also included the SweetAlert css and js to the page which works if I put this code
$(function () {
$("#<%= btnHidden.ClientID%>").click(function () {
swal("Please Provide All Valid Message Information!");
return true;
});
});
如果你能帮助我解决这个问题,我会非常感激你。
问候
SMHasnain
I will much greatfull to you if you could help me solve this problem.
Regards
SMHasnain
推荐答案
(function(){
(function () {
(#< span class =code-pagedirective><% = btnHidden.ClientID %> )。click(function(){
swal(请提供所有有效的消息信息!);
返回true;
});
});
("#<%= btnHidden.ClientID%>").click(function () { swal("Please Provide All Valid Message Information!"); return true; }); });
我如果你能帮我解决这个问题,你会非常感激。
问候
SMHasnain
I will much greatfull to you if you could help me solve this problem.
Regards
SMHasnain
感谢所有我找到了解决问题的方法,我只是关闭更新面板中的按钮并使用一个scriptmansger。
Thanks to all I found a solution for my problem, I just to close the button in update pannel and use a scriptmansger over it.
<script type="text/javascript">
function Showalert() {
这篇关于ScriptManager不使用自定义警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!