Welcome Guest Search | Active Topics | Sign In | Register

MaskedEdit display during JavaScript alert Options
Kris Brietkopf
Posted: Thursday, July 24, 2008 5:50:04 AM
Rank: Member
Groups: Member

Joined: 3/24/2008
Posts: 12
I have a MasterPage/Content page website. I use a callback panel so in order to display JavaScript messages I use your label method. I wrote the function below to make it generic.

Function PopupMsg(ByVal msg As String, ByVal currentCtl As String) As String
'use this technique to popup a message box from inside a callback panel
'normal RegisterClientScriptBlock for Javascript won't work

Dim content As ContentPlaceHolder
content = Page.Master.FindControl("PageContent")

Dim crtl As Control
crtl = content.FindControl(currentCtl)

Dim sScript As String = ""
sScript = "<script type='text/javascript'>"
sScript += "window.alert('" + msg + "');"
sScript += "document.getElementById('" + crtl.ClientID + "').focus();"
sScript += "</script>"


PopupMsg = sScript
End Function

I have noticed that when I popup a message box this way on a content page any data already in a MaskedEdit box is temporarily invisible. If you do the same thing on a regular web page (no master page) or if you use the .net msgbox this issue doesn't come up.

Do I need to set some property to use the MaskedEdit box in this scenerio? Can you give me a solution to this issue? I would like to see the data entered into the MaskedEdit box even when a JavaScript alert is being displayed.

Thanks.
eo_support
Posted: Thursday, July 24, 2008 7:22:27 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,193
Hi,

try to use window.setTimeout to delay the message, for example, instead of window.alert('abc'), do window.setTimeout("window.alert('abc')", 10);

MasterPage should not matter as it's purely a server side concept. Once the page is rendered, contents of the master page and content page are merged together. So in theory whether you use a master page should not matter as to client side functionality.

The content of the master page does matter, because it go to the client side the same way as the content of the content page. So you may want to gradually comment out blocks in your master page to find out the triggering point.

In anyway if you have a page that reproduces the problem, please let us know. Make sure the page does not rely on anything else. As soon as we can run it and see the problem, we should be able to find a solution.

Thanks

Kris Brietkopf
Posted: Friday, July 25, 2008 1:59:48 PM
Rank: Member
Groups: Member

Joined: 3/24/2008
Posts: 12
I was able to isolate this problem down to a single web page. The code is pasted in below.

Default.aspx source:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<%@ Register assembly="EO.Web" namespace="EO.Web" tagprefix="eo" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div style="text-align: center; font-size: large">

TEST FORM<br />
<br />
<br />


<div id="Headshots" style="width: 728px" >

<eo:CallbackPanel id="CallbackPanel1" runat="server" Width="728px"
Triggers="{ControlID:cmdNext;Parameter:}"
style="margin-right: 0px" UpdateMode="Self">

<table style="width: 720px">
<tr>
<td align="center">
&nbsp;&nbsp; &nbsp;<asp:Button
ID="cmdNext" runat="server" Text="Press to Pop Up Message" Width="216px"
UseSubmitBehavior="False" CausesValidation="False" EnableViewState="False" />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<br />
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblPopUp" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td align="center">
&nbsp;</td>
</tr>
</table>

<eo:MultiPage ID="MultiPage1" runat="server" Width="727px">



<!-- Start of PageView1-->

<eo:PageView ID="PageView1" runat="server" Width="727px">


<table style="width: 720px">

<tr>
<td style="width: 220px; padding-right: 10px; text-align:right;">Name on cards:<span style="color: #FF0000">*</span></td>

<td style ="text-align:left; width: 260px;">

<asp:TextBox ID="txtNameOnCards" runat="server"
Width="250px"
ToolTip="Enter the name as you want it displayed on the headshot."></asp:TextBox>

</td>
<td style="text-align:left">
<eo:MaskedEdit ID="txtCreditCardNumber0" runat="server"
EnableKeyboardNavigation="True" ForceSSL="True" PromptChar=""
ToolTip="Enter credit card number." Width="200px">
<eo:MaskedEditSegment IsRequired="True" Mask="################"
MaxValue="1E+18" SegmentType="Mask" />
</eo:MaskedEdit>
</td>
</tr>
<tr>
<td style="width: 220px; padding-right: 10px; text-align:right;">Agent:</td>

<td style ="text-align:left" colspan="2">


<asp:TextBox ID="txtAgent" runat="server" Width="250px"></asp:TextBox>


</td>


</tr>

<tr>
<td style="width: 220px; padding-right: 10px; text-align: right;">Masked Edit Box:</td>

<td style="text-align:left" colspan="2">

<asp:TextBox ID="txtPhotographer" runat="server"
Width="250px"></asp:TextBox>
<br />
<br />
Enter something below.<br />
<eo:MaskedEdit ID="txtCreditCardNumber1" runat="server"
EnableKeyboardNavigation="True" ForceSSL="True" PromptChar=""
ToolTip="Enter credit card number." Width="200px">
<eo:MaskedEditSegment IsRequired="True" Mask="################"
MaxValue="1E+18" SegmentType="Mask" />
</eo:MaskedEdit>
<br />
<br />
<br />
</td>
</tr>



</table>



</eo:PageView>


</eo:MultiPage>


</eo:CallbackPanel>


</div>


</div>
</form>
</body>
</html>

Default.aspx.vb source:


Partial Class _Default
Inherits System.Web.UI.Page


Protected Sub cmdNext_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdNext.Click
lblPopUp.Text = PopupMsg("When you popup this message the data in the Masked Edit box disappears.", "txtNameOnCards")
End Sub


Function PopupMsg(ByVal msg As String, ByVal currentCtl As String) As String

Dim sScript As String = ""
sScript = "<script type='text/javascript'>"
sScript += "window.alert('" + msg + "');"
sScript += "document.getElementById('" + currentCtl + "').focus();"
sScript += "</script>"

PopupMsg = sScript
End Function
End Class

Enter some text in the Masked Edit box and push the button. The text disappears while the messagebox is visible. When you clear the message box the text comes back.

Let me know if you can reproduce this or not.
Thanks!

eo_support
Posted: Friday, July 25, 2008 2:43:43 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,193
Hi,

You can use setTimeout to workaround this:

Dim sScript As String = ""
sScript = "<script type='text/javascript'>"
sScript += "setTimeout("
sScript += "function() {"
sScript += "window.alert('" + msg + "');"
sScript += "document.getElementById('" + currentCtl + "').focus();}"
sScript += ",1);"
sScript += "</script>"

Thanks
Kris Brietkopf
Posted: Friday, July 25, 2008 3:13:29 PM
Rank: Member
Groups: Member

Joined: 3/24/2008
Posts: 12
This works. Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.