I am writing a web application for my company (VB.NET). I am adding a custom
web form class to prevent all the code reuse as you can see below...
Public Class UIWebForm
Inherits System.Web.UI.P age
Here I have a Public Sub that will use a ASP Literal on the page to display
a javascript alert message...
Protected WithEvents ltlAlert As System.Web.UI.W ebControls.Lite ral
Public Sub ShowAlertMessag e(ByVal Message As String)
' Format string properly
Message = FormatJavaScrip tMessage(Messag e)
' Display as JavaScript alert
ltlAlert.Text = "alert('" & Message & "')"
End Sub
Public Function FormatJavaScrip tMessage(ByVal Message As String) As
String
Message = Message.Replace ("'", "\'")
Message = Message.Replace (Convert.ToChar (10), "\n")
Message = Message.Replace (Convert.ToChar (13), "")
Return Message
End Function
I need to drop the ASP Literal control onto my webform as follows to get
this to work...
<script>
<asp:Literal id="ltlAlert" runat="server"
EnableViewState ="False"></asp:Literal>
</script>
Is there a way that I can have the above code also enter on my page
automatically so that I do not have to enter it on every page that create.
Can I add when the controls render or anything? I cannot think of the
specific funcitons I would need to call or implement