Lefteris Gkinis
Lefteris Gkinis

Reputation: 1259

PopUp Alert Window problems

I have this script in order to run an alert window:

<asp:Content ID="RegisterMain" ContentPlaceHolderID="MainContent" runat="server">
<script language="javascript" type="text/javascript">
    function popup(msg) {
        window.alert(msg);
        window.window.focus();
    }
    </script>
.........
</asp:Content>

And I also have this procedure in code behind to run this script:

Public Sub PostError(inheretedPage As System.Web.UI.Page, sender As Object, msg As String)
        Dim cstype As Type = inheretedPage.GetType()
        Dim innerMess As String = msg
        Dim url As String = HttpContext.Current.Request.Url.AbsoluteUri
        Dim script As String = "popup('" & innerMess & "')"
        If Not Page.ClientScript.IsStartupScriptRegistered(inheretedPage.GetType(), "alertscript") Then
            Page.ClientScript.RegisterStartupScript(cstype, "alertscript", script, True)
        End If
    End Sub

Everything goes well when I run the following instruction directly from the code behind, and before it starts anything:

PostError(Me, sender, "Your e-mail address is not good")

The program goes further into a class in order to make the process for Data Base and the Server.
In case of error inside the class I use this line to return the error for display.

Catch ex As OleDbException
                Dim SHandler As New Web.SQLServer.DBHandler
                ErrorAnswer = SHandler.GetError(ServerConn.Provider, ex, Nothing)
                retVal = False
 End Try
            Return retVal & "|" & faultReason & "|" & ErrorAnswer

In this case I'm taking back the error message into the code behind, as a returned variable from the Class, and handle it inside of this procedure with the following instruction:

ErrorAnswer = "Server is open, and base is closed"
                        PostError(Me, sender, ErrorAnswer)  

As we can see the instruction is the same in both cases, at the first and in way of code execution.
Now my issue is that the Direct instruction pass from the script and executed just fine, but the indirect (which comes from the Class) did not execute the script even she has all the variable just the same like the direct.
Script is not called in the second case.

ADITIONAL INFORMATIONS
In the first case the procedure PostError has:
cstype = {Name = "pages_account_register_aspx" FullName = ASP.pages_account_register_aspx"}<br/> popup('Your e-mail is not right')

And in the second case the same porcedure has:
cstype = {Name = "pages_account_register_aspx" FullName = ASP.pages_account_register_aspx"}<br/> script = "popup('Login timeout expired')"

Upvotes: 0

Views: 121

Answers (1)

Lefteris Gkinis
Lefteris Gkinis

Reputation: 1259

I finally found the problem... The script is not accept the vbCrLf this command is not executed from the script... Thank you alll

Upvotes: 1

Related Questions