473,387 Members | 1,483 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

ASP.NET Message Box causing problems with SmartNavigation property

Hello everyone

I just use a MsgBox component for ASP.NET using Methods such as Render and
OnPreRender and JavaScript involved to get a simple Confirmation Box in
client side, but the funny thing is when I go SmartNavigation property equal
True the MessageBox does not come up!

But if you open another window and return to the browser you can see the
pop-up window !!!

Any Suggestions?

This is the complete code to Confirmation Pop-up:

Imports System.ComponentModel
Imports System.Web.UI
Imports System.Web.UI.WebControls

Public Class MsgBox
Inherits System.Web.UI.WebControls.WebControl
Implements IPostBackEventHandler

Private _Message As String
Private _Key As String
Private _PostBackOnYes As Boolean
Private _PostBackOnNo As Boolean

Public Event YesChoosed(ByVal sender As Object, ByVal Key As String)
Public Event NoChoosed(ByVal sender As Object, ByVal Key As String)

Public Sub ShowConfirmation(ByVal Message As String, ByVal Key As
String, ByVal PostBackOnYes As Boolean, ByVal PostBackOnNo As Boolean)
_Message = "ÑaÑa" & Message
_Key = Key
_PostBackOnYes = PostBackOnYes
_PostBackOnNo = PostBackOnNo
End Sub

Public Sub ShowMessage(ByVal Message As String)
_Message = Message
End Sub

Protected Overrides Sub OnPreRender(ByVal e As EventArgs)
If Not MyBase.Page.IsClientScriptBlockRegistered("MsgBox" ) Then
Page.RegisterClientScriptBlock("MsgBox", FuncionJava1())
End Sub

Private Function FuncionJava1() As String
Dim miPostBackOnYes As String = "MsgBoxTextoMensaje="""";"
Dim miPostBackOnNo As String = "MsgBoxTextoMensaje="""";"

If _PostBackOnYes Then
miPostBackOnYes = Page.GetPostBackEventReference(Me, "Yes" & _Key)
End If
If _PostBackOnNo Then
miPostBackOnNo = Page.GetPostBackEventReference(Me, "No_" & _Key)
End If

Return "<script language=""javascript""> " & _
"var MsgBoxTipoMensaje; " & _
"var MsgBoxTextoMensaje; " & _
"window.attachEvent(""onfocus"", MsgBoxMostrarMensaje); " & _
"function MsgBoxMostrarMensaje() { " & _
"if (MsgBoxTextoMensaje) { " & _
"if (MsgBoxTextoMensaje != """") { " & _
"if (MsgBoxTipoMensaje==2) {" & _
" alert(MsgBoxTextoMensaje); " & _
"} else {" & _
"if (confirm(MsgBoxTextoMensaje)) { " & _
miPostBackOnYes & _
"} else { " & _
miPostBackOnNo & _
"}} MsgBoxTextoMensaje=""""; " & _
" }}} </script>"
End Function
<Security.Permissions.PermissionSetAttribute(Secur ity.Permissions.SecurityAction.Demand, Name:="FullTrust")> _
Protected Overrides Sub Render(ByVal writer As
System.Web.UI.HtmlTextWriter)
If ModoDisenio(Me) Then
writer.Write(Me.ID)
Else
If _Message <> String.Empty Then
Dim miSB As System.Text.StringBuilder = New
System.Text.StringBuilder(_Message)
miSB.Replace(Microsoft.VisualBasic.vbCr, " "c)
miSB.Replace(Microsoft.VisualBasic.vbLf, " "c)
miSB.Replace("""", "'"c)

If miSB.ToString.StartsWith("ÑaÑa") Then
Me.Page.Response.Write("<script>MsgBoxTipoMensaje= 1;
MsgBoxTextoMensaje=""" + _
miSB.ToString.Substring(4) + """;</script>")
Else
Me.Page.Response.Write("<script>MsgBoxTipoMensaje= 2;
MsgBoxTextoMensaje=""" + _
miSB.ToString + """;</script>")
End If
miSB = Nothing
End If
End If
End Sub

Private Shared Function ModoDisenio(ByVal QueControl As _
System.Web.UI.WebControls.WebControl) As Boolean
Dim DesignMode As Boolean = False
Try
DesignMode = QueControl.Site.DesignMode
Catch : End Try
Return DesignMode
End Function

Public Sub RaisePostBackEvent(ByVal eventArgument As String) _
Implements IPostBackEventHandler.RaisePostBackEvent
Select Case eventArgument.Substring(0, 3)
Case "Yes"
RaiseEvent YesChoosed(Me, eventArgument.Substring(3))
Case "No_"
RaiseEvent NoChoosed(Me, eventArgument.Substring(3))
End Select
End Sub

End Class
************************************************

You can save this code and generate a Component, after that I am using this
code:

MsgBox1.ShowConfirmation("Do you want to delete this record?", "BORRAR",
True, False)

AND if you click and SmartNavigation equal True the Windows will not comes up!

I realized that and some computers does not appear the window even if the
NavigationSmart is False !!!

Any Suggestions????
--
Regards,
Martz
Nov 19 '05 #1
1 2736
Hi Martz:

SmartNav causes all sorts of difficulties when JavaScript and DHTML
are involved on the page. The only good workaround is to get rid of
SmartNav.

If you need to persist scroll position, there are some techniques to
do that for 1.1 on the web.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Thu, 28 Jul 2005 07:58:04 -0700, "Martz"
<Ma***@discussions.microsoft.com> wrote:
Hello everyone

I just use a MsgBox component for ASP.NET using Methods such as Render and
OnPreRender and JavaScript involved to get a simple Confirmation Box in
client side, but the funny thing is when I go SmartNavigation property equal
True the MessageBox does not come up!

But if you open another window and return to the browser you can see the
pop-up window !!!

Any Suggestions?

This is the complete code to Confirmation Pop-up:

Imports System.ComponentModel
Imports System.Web.UI
Imports System.Web.UI.WebControls

Public Class MsgBox
Inherits System.Web.UI.WebControls.WebControl
Implements IPostBackEventHandler

Private _Message As String
Private _Key As String
Private _PostBackOnYes As Boolean
Private _PostBackOnNo As Boolean

Public Event YesChoosed(ByVal sender As Object, ByVal Key As String)
Public Event NoChoosed(ByVal sender As Object, ByVal Key As String)

Public Sub ShowConfirmation(ByVal Message As String, ByVal Key As
String, ByVal PostBackOnYes As Boolean, ByVal PostBackOnNo As Boolean)
_Message = "ÑaÑa" & Message
_Key = Key
_PostBackOnYes = PostBackOnYes
_PostBackOnNo = PostBackOnNo
End Sub

Public Sub ShowMessage(ByVal Message As String)
_Message = Message
End Sub

Protected Overrides Sub OnPreRender(ByVal e As EventArgs)
If Not MyBase.Page.IsClientScriptBlockRegistered("MsgBox" ) Then
Page.RegisterClientScriptBlock("MsgBox", FuncionJava1())
End Sub

Private Function FuncionJava1() As String
Dim miPostBackOnYes As String = "MsgBoxTextoMensaje="""";"
Dim miPostBackOnNo As String = "MsgBoxTextoMensaje="""";"

If _PostBackOnYes Then
miPostBackOnYes = Page.GetPostBackEventReference(Me, "Yes" & _Key)
End If
If _PostBackOnNo Then
miPostBackOnNo = Page.GetPostBackEventReference(Me, "No_" & _Key)
End If

Return "<script language=""javascript""> " & _
"var MsgBoxTipoMensaje; " & _
"var MsgBoxTextoMensaje; " & _
"window.attachEvent(""onfocus"", MsgBoxMostrarMensaje); " & _
"function MsgBoxMostrarMensaje() { " & _
"if (MsgBoxTextoMensaje) { " & _
"if (MsgBoxTextoMensaje != """") { " & _
"if (MsgBoxTipoMensaje==2) {" & _
" alert(MsgBoxTextoMensaje); " & _
"} else {" & _
"if (confirm(MsgBoxTextoMensaje)) { " & _
miPostBackOnYes & _
"} else { " & _
miPostBackOnNo & _
"}} MsgBoxTextoMensaje=""""; " & _
" }}} </script>"
End Function
<Security.Permissions.PermissionSetAttribute(Secu rity.Permissions.SecurityAction.Demand, Name:="FullTrust")> _
Protected Overrides Sub Render(ByVal writer As
System.Web.UI.HtmlTextWriter)
If ModoDisenio(Me) Then
writer.Write(Me.ID)
Else
If _Message <> String.Empty Then
Dim miSB As System.Text.StringBuilder = New
System.Text.StringBuilder(_Message)
miSB.Replace(Microsoft.VisualBasic.vbCr, " "c)
miSB.Replace(Microsoft.VisualBasic.vbLf, " "c)
miSB.Replace("""", "'"c)

If miSB.ToString.StartsWith("ÑaÑa") Then
Me.Page.Response.Write("<script>MsgBoxTipoMensaje= 1;
MsgBoxTextoMensaje=""" + _
miSB.ToString.Substring(4) + """;</script>")
Else
Me.Page.Response.Write("<script>MsgBoxTipoMensaje= 2;
MsgBoxTextoMensaje=""" + _
miSB.ToString + """;</script>")
End If
miSB = Nothing
End If
End If
End Sub

Private Shared Function ModoDisenio(ByVal QueControl As _
System.Web.UI.WebControls.WebControl) As Boolean
Dim DesignMode As Boolean = False
Try
DesignMode = QueControl.Site.DesignMode
Catch : End Try
Return DesignMode
End Function

Public Sub RaisePostBackEvent(ByVal eventArgument As String) _
Implements IPostBackEventHandler.RaisePostBackEvent
Select Case eventArgument.Substring(0, 3)
Case "Yes"
RaiseEvent YesChoosed(Me, eventArgument.Substring(3))
Case "No_"
RaiseEvent NoChoosed(Me, eventArgument.Substring(3))
End Select
End Sub

End Class
*********************************************** *

You can save this code and generate a Component, after that I am using this
code:

MsgBox1.ShowConfirmation("Do you want to delete this record?", "BORRAR",
True, False)

AND if you click and SmartNavigation equal True the Windows will not comes up!

I realized that and some computers does not appear the window even if the
NavigationSmart is False !!!

Any Suggestions????


Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Chris Ruegsegger | last post by:
I have a registration type page that asks a series of questions but does so using Panels to display only a couple at a time. I have a Next and Back button on each panel for navigation purposes. ...
2
by: SLE | last post by:
A web user control exposes a RadioButtonList (with AutoPostBack = true) called "Question". This control also has an embedded RequiredFieldValidator control. 1. Main ASPX page is populated with...
2
by: Sleepy | last post by:
I have a situation where my stylesheet seems to be ignored when I set the smartNavigation property to True. Can someone please tell me what I'm doing wrong or how I should be doing this I have a...
3
by: Brad | last post by:
I have an aspx web page which initially displays fine. When I postback the resulting response back to the client output is causing InternetExplorer 6 to crash. I've disabled the server side code...
3
by: Nestus | last post by:
Hi, im developing a solution in ASP.Net, i have a page that i need to use the smartnavigation in true, the problem occurs when i put in the directive @Page SmartNavigation = true my page trhows a...
2
by: WJ | last post by:
I have a web site with 2 pages under W2k3 box (IIS-6). 1. From WebForm1.Aspx.Button1Click, I issued Response.Redirect("WebForm2.Aspx",true) - This works fine. 2. From WebForm2.Aspx.Button1Click,...
0
by: stacy | last post by:
I used the wizard to upgrade an application from VB 6 to VB.net, the following warnings appear around the .Input property of the MSCOmm control 'UPGRADE_WARNING: Couldn't resolve default property...
7
by: Kewlpack | last post by:
Okay - this is stumping me. I've used .Net since 1.0 release and never had this trouble before... In one of my new projects, if I enable the SmartNavigation="True" in the Page...
3
by: cmay | last post by:
I have just started created a web app in asp.net 2.0. I am using a masterpage for header/footer stuff. In my content page I am using MaintainScrollPositionOnPostback, and while it does keep...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.