admin管理员组文章数量:1291174
How to use Java script alert msg in code behind? This message will be display after save the data.
Here is my code,
enter code here
Protected Sub Add_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Add.Click
'add new class
Dim DbClassMst = New ClassMst()
Dim dsClass As DataSet
Dim status As Integer = 0
Dim ResourceObject As Object
' 画面リソース定義
If SessionCtl.GetSession("RES_LANG").ToString = ResourceBase.LOCALE_JA Then
ResourceObject = New ResourceJa(SessionCtl.GetSession("RES_LANG"))
Else
ResourceObject = New ResourceEn(SessionCtl.GetSession("RES_LANG"))
End If
If NewClass.Text = "" Then
lblErrMsg.Text = ResourceObject.getMsg(ResourceBase.NEW_CLASS_REG)
Exit Sub
Else
'check to allow unique class
dsClass = DbClassMst.DisplayClass1(NewClass.Text)
If Trim(dsClass.Tables(0).Rows.Count > 0) Then
status = 1
End If
If dsClass.Tables(0).Rows.Count < 10 Then
If status = 0 Then
'insert class
DbClassMst.InsertClassNew(NewClass.Text, dsClass.Tables(0).Rows.Count + 1)
PopulateClassName()
NewClass.Text = ""
Dim AlertMsg As String = ""
AlertMsg = "<script language='javascript'>alert('Data has been saved');</script>"
*********Here I need alert msg.
Else
lblErrMsg.Text = ResourceObject.getMsg(ResourceBase.NEW_CLASS_EXIST)
Exit Sub
End If
Else
lblErrMsg.Text = ResourceObject.getMsg(ResourceBase.NEW_CLASS_MAX)
End If
End If
End Sub
but is not working. give me an idea.
How to use Java script alert msg in code behind? This message will be display after save the data.
Here is my code,
enter code here
Protected Sub Add_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Add.Click
'add new class
Dim DbClassMst = New ClassMst()
Dim dsClass As DataSet
Dim status As Integer = 0
Dim ResourceObject As Object
' 画面リソース定義
If SessionCtl.GetSession("RES_LANG").ToString = ResourceBase.LOCALE_JA Then
ResourceObject = New ResourceJa(SessionCtl.GetSession("RES_LANG"))
Else
ResourceObject = New ResourceEn(SessionCtl.GetSession("RES_LANG"))
End If
If NewClass.Text = "" Then
lblErrMsg.Text = ResourceObject.getMsg(ResourceBase.NEW_CLASS_REG)
Exit Sub
Else
'check to allow unique class
dsClass = DbClassMst.DisplayClass1(NewClass.Text)
If Trim(dsClass.Tables(0).Rows.Count > 0) Then
status = 1
End If
If dsClass.Tables(0).Rows.Count < 10 Then
If status = 0 Then
'insert class
DbClassMst.InsertClassNew(NewClass.Text, dsClass.Tables(0).Rows.Count + 1)
PopulateClassName()
NewClass.Text = ""
Dim AlertMsg As String = ""
AlertMsg = "<script language='javascript'>alert('Data has been saved');</script>"
*********Here I need alert msg.
Else
lblErrMsg.Text = ResourceObject.getMsg(ResourceBase.NEW_CLASS_EXIST)
Exit Sub
End If
Else
lblErrMsg.Text = ResourceObject.getMsg(ResourceBase.NEW_CLASS_MAX)
End If
End If
End Sub
but is not working. give me an idea.
Share Improve this question edited Sep 26, 2009 at 9:05 VJS asked Sep 26, 2009 at 8:34 VJSVJS 1,1514 gold badges11 silver badges20 bronze badges 03 Answers
Reset to default 6A better way to do this is to have this as a utility method in a mon class:
Friend Module MyUtilities
Public Sub Alert(ByVal page As Page, ByVal message As String)
Dim alertMessage As String = "alert('" & message & "');"
page.ClientScript.RegisterStartupScript(page.[GetType](), "showAlert", alertMessage, True)
End Sub
End Module
This can be used in a page like this:
MyUtilities.Alert(Me, "Sample alert!!!!!")
Your code looks so simpler. Hope this helps!
You should register this script to your page, so this script will be sent to the client.
Page.ClientScript.RegisterStartupScript(typeof(YourPage),
"myScripts",
"<script language='javascript'>alert('Data has been saved');</script>");
Dim someScript As String = "" someScript = "alert('Your Leave request has been registered');" Page.ClientScript.RegisterStartupScript(Me.GetType(), "onload", someScript)
本文标签: javascriptJava script alert msg in code behind Aspnet 35Stack Overflow
版权声明:本文标题:javascript - Java script alert msg in code behind Asp.net 3.5 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741525490a2383440.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论