|
 |
aspx_beginners thread: Popup window in ASP.NET?
Message #1 by "Stephanie Patterson" <stephanie.l.patterson@i...> on Tue, 16 Apr 2002 19:34:54
|
|
How do I create a popup window on the client while in the middle of
ASP.NET <script language="vb" runat="server"> tag?
Basically, this is what I need:
sub x
...
if cond then
display popup window
endif
...
end sub
Any and all help is GREATLY appreciated.
Stephanie
Message #2 by "Dmitry Brook" <brook74@h...> on Tue, 16 Apr 2002 19:04:19 +0000
|
|
Hi ! Straightforward... just paste a piece of JScript right into your ASP
page like(ASP or ASP.NET doesn't matter):
...
if ServerVar = YourValue then
%>
<script language=javascript>
window.open(blah..blah..blah...);
</script>
<%
end if
...
That's it...
>From: "Stephanie Patterson" <stephanie.l.patterson@i...>
>Reply-To: "aspx_beginners" <aspx_beginners@p...>
>To: "aspx_beginners" <aspx_beginners@p...>
>Subject: [aspx_beginners] Popup window in ASP.NET?
>Date: Tue, 16 Apr 2002 19:34:54
>
>How do I create a popup window on the client while in the middle of
>ASP.NET <script language="vb" runat="server"> tag?
>
>Basically, this is what I need:
>
>sub x
> ...
>
> if cond then
> display popup window
> endif
>
> ...
>
>end sub
>
>Any and all help is GREATLY appreciated.
>Stephanie
_________________________________________________________________
Join the world?s largest e-mail service with MSN Hotmail.
http://www.hotmail.com
Message #3 by "Stephanie Patterson" <stephanie.l.patterson@i...> on Tue, 16 Apr 2002 20:27:07
|
|
Thanks, but I'm sorry, I wasn't clear in my first post. I'm not working
within the <% ... %>, I'm using <script language="vb" runat="server"> ...
</script>.
Here's a better representation of what I need:
<script language="vb" runat="server">
Sub X
...
if cond then
display popup window
endif
....
end sub
</script>
Thanks again!
Stephanie
Message #4 by "Dmitry Brook" <brook74@h...> on Tue, 16 Apr 2002 20:31:55 +0000
|
|
Doesn't make any scenes.. The main is to understand what is HTML stream...
Paste that block into any appopriate place.
>From: "Stephanie Patterson" <stephanie.l.patterson@i...>
>Reply-To: "aspx_beginners" <aspx_beginners@p...>
>To: "aspx_beginners" <aspx_beginners@p...>
>Subject: [aspx_beginners] Re: Popup window in ASP.NET?
>Date: Tue, 16 Apr 2002 20:27:07
>
>Thanks, but I'm sorry, I wasn't clear in my first post. I'm not working
>within the <% ... %>, I'm using <script language="vb" runat="server"> ...
></script>.
>
>Here's a better representation of what I need:
>
><script language="vb" runat="server">
> Sub X
> ...
> if cond then
> display popup window
> endif
> ....
> end sub
></script>
>
>Thanks again!
>Stephanie
>
_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com
Message #5 by Julian Voelcker <asp@t...> on Tue, 16 Apr 2002 23:03:04 +0100
|
|
You can only pop up a window from the client side, and the only way to do it is
with the JavaScript window.open(....) Function.
If your code is rendering a page and you want to pop up the window when the page
is rendered, you need to get it to render the block of javascript code that
Dmitry provided.
Cheers,
Julian Voelcker
The Virtual World (UK) Limited
Cirencester, United Kingdom
On Tue, 16 Apr 2002 19:34:54, Stephanie Patterson wrote:
> How do I create a popup window on the client while in the middle of
> ASP.NET <script language="vb" runat="server"> tag?
>
> Basically, this is what I need:
>
> sub x
> ...
>
> if cond then
> display popup window
> endif
>
> ...
>
> end sub
>
> Any and all help is GREATLY appreciated.
> Stephanie
>
Message #6 by "Benjamin D. Gray" <bdgray@g...> on Tue, 16 Apr 2002 16:28:54 -0600
|
|
Do want something like this:
<script language="vb" runat="server">
Sub X()
...
If cond Then
Response.Write "<script language=""javascript"">" & vbCrLf
Response.Write " window.open(blah..blah..blah...);" & vbCrLf
Response.Write "</script>" & vbCrLf
End If
....
End Sub
</script>
If you could show us the code that calls sub X() that would be helpful.
Benjamin D. Gray
WCIS Career Portfolio Web Developer
http://uwyo.edu/wcis/portfolio/
Message #7 by "Stephanie Patterson" <stephanie.l.patterson@i...> on Wed, 17 Apr 2002 16:11:21
|
|
Please note, I'm new to this type of web development, including ASP.NET
and ASP. There are probably better ways to do some of what I'm doing, but
I'm still learning. All advise and help is GREATLY appreciated!
This is a scaled-down version of what I'm trying to do, I put **** around
the area where I'm needing the pop-up window:
<%@ Import Namespace="System.Object" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.IO" %>
<script language="vb" runat="server">
Sub Page_Load()
' first time through, assign variables, otherwise skip
If Trim(Session("strIDSID")) = "" Then
'get full username and login id
End If
End Sub
Function fnConnection(strDBName as String)
'assign variable the connection string
'find out which server is being used
'connect to database
end Function
Sub UploadFile(objSource As Object, objArgs As EventArgs)
'This procedure uploads user's file to the server and updates the
'tracking database with file ownership information.
Dim strFullUpFileNm as String = MyFileInput.PostedFile.Filename
Dim strUpFileNm as String
Dim strUpFileSize as String = MyFileInput.PostedFile.ContentLength
Dim strSaveAsNm as String
Dim strUpFileExt as String
Dim strSaveAsPath as String
Dim objDataReader as SqlDataReader
If (Trim(MyFileInput.PostedFile.Filename) <> "") Then
'Check to see if the file exists in the destination folder
If System.IO.File.Exists(strSaveAsPath & strSaveAsNm) Then
'check database to see if user is file owner
If Session("strWWID") = objDataReader.GetString(3) then
Else
'someone else owns the file - display error message
'*****************************************************************
'*** have pop-up window display that someone else owns the file
'*****************************************************************
End If
Else
'file is a new posting; need to add to db & upload file to server
End IF
Else
'error - upload filename is blank
End If
End Sub
</script>
<h2>Upload Files</h2>
<form id="Form1" enctype="multipart/form-data" runat="server">
<table id="Table1" class="fontdefault" cellspacing="0" cellpadding="2">
<tr valign="top">
<td>Choose File to Upload
<br><input type="file" id="MyFileInput" size="70" runat="server"
NAME="MyFileInput">
</td>
</tr>
<tr valign="top">
<td width="50"> </td>
<td>
<asp:requiredfieldvalidator
id="ReqFldFileInput"
controltovalidate="MyFileInput"
text="."
initialvalue=""
errormessage="* Input file not selected"
runat="server"/>
</td>
</tr>
<tr valign="top">
<td>
<input type="button" id="SubmitButton" value="Upload File"
runat="server" onserverclick="UploadFile" NAME="SubmitButton">
</td>
</tr>
<tr valign="top">
<td><br />Upload Success Information<br />
<textarea id="UpFileTextArea" rows="5" cols="65"
runat="server" NAME="UpFileTextArea"></textarea>
</td>
</tr>
</table>
<br /><br />
<asp:validationsummary
id="ValidationSummary3"
runat="server"
DisplayMode="List"
ShowMessageBox="True">
</asp:validationsummary>
</form>
<div id="outError" runat="server"></div>
Message #8 by "Dmitry Brook" <brook74@h...> on Wed, 17 Apr 2002 15:34:41 +0000
|
|
Do ya understand English ? ;-)
>From: "Stephanie Patterson" <stephanie.l.patterson@i...>
>Reply-To: "aspx_beginners" <aspx_beginners@p...>
>To: "aspx_beginners" <aspx_beginners@p...>
>Subject: [aspx_beginners] RE: Popup window in ASP.NET?
>Date: Wed, 17 Apr 2002 16:11:21
>
>Please note, I'm new to this type of web development, including ASP.NET
>and ASP. There are probably better ways to do some of what I'm doing, but
>I'm still learning. All advise and help is GREATLY appreciated!
>
>This is a scaled-down version of what I'm trying to do, I put **** around
>the area where I'm needing the pop-up window:
>
><%@ Import Namespace="System.Object" %>
><%@ Import Namespace="System.Data" %>
><%@ Import Namespace="System.Data.SqlClient" %>
><%@ Import Namespace="System.IO" %>
>
><script language="vb" runat="server">
>
> Sub Page_Load()
> ' first time through, assign variables, otherwise skip
> If Trim(Session("strIDSID")) = "" Then
> 'get full username and login id
> End If
> End Sub
>
> Function fnConnection(strDBName as String)
> 'assign variable the connection string
> 'find out which server is being used
> 'connect to database
> end Function
>
> Sub UploadFile(objSource As Object, objArgs As EventArgs)
> 'This procedure uploads user's file to the server and updates the
> 'tracking database with file ownership information.
> Dim strFullUpFileNm as String = MyFileInput.PostedFile.Filename
> Dim strUpFileNm as String
> Dim strUpFileSize as String = MyFileInput.PostedFile.ContentLength
> Dim strSaveAsNm as String
> Dim strUpFileExt as String
> Dim strSaveAsPath as String
> Dim objDataReader as SqlDataReader
>
> If (Trim(MyFileInput.PostedFile.Filename) <> "") Then
> 'Check to see if the file exists in the destination folder
> If System.IO.File.Exists(strSaveAsPath & strSaveAsNm) Then
> 'check database to see if user is file owner
> If Session("strWWID") = objDataReader.GetString(3) then
> Else
> 'someone else owns the file - display error message
>
>'*****************************************************************
> '*** have pop-up window display that someone else owns the file
>
>'*****************************************************************
> End If
> Else
> 'file is a new posting; need to add to db & upload file to server
> End IF
> Else
> 'error - upload filename is blank
> End If
> End Sub
>
></script>
>
><h2>Upload Files</h2>
><form id="Form1" enctype="multipart/form-data" runat="server">
> <table id="Table1" class="fontdefault" cellspacing="0" cellpadding="2">
> <tr valign="top">
> <td>Choose File to Upload
> <br><input type="file" id="MyFileInput" size="70" runat="server"
>NAME="MyFileInput">
> </td>
> </tr>
> <tr valign="top">
> <td width="50"> </td>
> <td>
> <asp:requiredfieldvalidator
> id="ReqFldFileInput"
> controltovalidate="MyFileInput"
> text="."
> initialvalue=""
> errormessage="* Input file not selected"
> runat="server"/>
> </td>
> </tr>
> <tr valign="top">
> <td>
> <input type="button" id="SubmitButton" value="Upload File"
> runat="server" onserverclick="UploadFile" NAME="SubmitButton">
> </td>
> </tr>
> <tr valign="top">
> <td><br />Upload Success Information<br />
> <textarea id="UpFileTextArea" rows="5" cols="65"
> runat="server" NAME="UpFileTextArea"></textarea>
> </td>
> </tr>
>
> </table>
> <br /><br />
> <asp:validationsummary
> id="ValidationSummary3"
> runat="server"
> DisplayMode="List"
> ShowMessageBox="True">
> </asp:validationsummary>
>
></form>
><div id="outError" runat="server"></div>
>
_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com
Message #9 by "Stephanie Patterson" <stephanie.l.patterson@i...> on Wed, 17 Apr 2002 17:22:14
|
|
Dmitry, yes. Your comment was unwelcomed and not helpful!
Neither your nor Benjamin's suggestion worked. In both cases, I receive
and error: Compiler Error Message: BC30081: 'If' must end with a
matching 'End If'.
At Benjamin's request, I provided the code. As I said, I'm learning. I
came here for help and am only receiving snide comments from you.
> Do ya understand English ? ;-)
Message #10 by "JAMES DONAHUE" <JDONAHUE@F...> on Wed, 17 Apr 2002 10:17:33 -0600
|
|
Don't be discouraged Steph!!!!
>>> stephanie.l.patterson@i... 04/17 5:22 PM >>>
Dmitry, yes. Your comment was unwelcomed and not helpful!
Neither your nor Benjamin's suggestion worked. In both cases, I receive
and error: Compiler Error Message: BC30081: 'If' must end with a
matching 'End If'.
At Benjamin's request, I provided the code. As I said, I'm learning. I
came here for help and am only receiving snide comments from you.
> Do ya understand English ? ;-)
Message #11 by "Curtner, Lynn" <lynn.curtner@p...> on Wed, 17 Apr 2002 11:18:56 -0500
|
|
Yeah, Dmitry, take a pill or something...
> ----------
> From: Stephanie Patterson[SMTP:stephanie.l.patterson@i...]
> Reply To: aspx_beginners
> Sent: Wednesday, April 17, 2002 12:22 PM
> To: aspx_beginners
> Subject: [aspx_beginners] RE: Popup window in ASP.NET?
>
> Dmitry, yes. Your comment was unwelcomed and not helpful!
>
> Neither your nor Benjamin's suggestion worked. In both cases, I receive
> and error: Compiler Error Message: BC30081: 'If' must end with a
> matching 'End If'.
>
> At Benjamin's request, I provided the code. As I said, I'm learning. I
> came here for help and am only receiving snide comments from you.
>
>
> > Do ya understand English ? ;-)
>
Message #12 by "Datatal AB - Gauffin, Jonas" <Jonas@d...> on Wed, 17 Apr 2002 18:21:47 +0200
|
|
You have got an answer (about client popup), right?
That errormessage tells you that your are missing an "End If" somewhere
in the code.
Here little suggestion:
Your orginal code:
If Session("strWWID") =3D objDataReader.GetString(3) then
Else
'someone else owns the file - display error message
'*****************************************************************
'*** have pop-up window display that someone else owns the file
'*****************************************************************
End If
hmm... why not:
If Session("strWWID") <> objDataReader.GetString(3) then
'someone else owns the file - display error message
'*****************************************************************
'*** have pop-up window display that someone else owns the file
'*****************************************************************
End If
> -----Original Message-----
> From: Stephanie Patterson [mailto:stephanie.l.patterson@i...]
> Sent: den 17 april 2002 19:22
> To: aspx_beginners
> Subject: [aspx_beginners] RE: Popup window in ASP.NET?
>
>
> Dmitry, yes. Your comment was unwelcomed and not helpful!
>
> Neither your nor Benjamin's suggestion worked. In both cases,
> I receive
> and error: Compiler Error Message: BC30081: 'If' must end with a
> matching 'End If'.
>
> At Benjamin's request, I provided the code. As I said, I'm
> learning. I
> came here for help and am only receiving snide comments from you.
>
>
> > Do ya understand English ? ;-)
>
>
Message #13 by Imar Spaanjaars <Imar@S...> on Wed, 17 Apr 2002 18:26:41 +0200
|
|
Hi Stephanie,
I think you are misunderstanding a very import point here, that's been made
quite a couple of times.
Your code inside the script blocks, runs server side. Server side you can't
have a message box (you wouldn't want someone clicking away half a million
dialog boxes on a very busy production server, would you ;-) )
So, if you want to show a dialog box, you have to do that on the client.
Suggestions for that have been made already: Use Response.Write to dump
client side JavaScript to the browser. The JavaScript show a message box at
the client.
So:
> If (Trim(MyFileInput.PostedFile.Filename) <> "") Then
> 'Check to see if the file exists in the destination folder
> If System.IO.File.Exists(strSaveAsPath & strSaveAsNm) Then
> 'check database to see if user is file owner
> If Session("strWWID") = objDataReader.GetString(3) then
> Else
> 'someone else owns the file - display error message
Dim sMessageBox as String
sMessageBox = "<scr" & "ipt" language=""JavaScript""
type=""text/javascript"">" & vbCrlf
sMessageBox &= alert('File is in use or whatever you want to show
here');"
sMessageBox &= "</scr" & "ipt">"
Response.Write(sMessageBox)
End If
> Else
> 'file is a new posting; need to add to db & upload file to server
> End IF
So in a web environment, the only way to get a message box is to show it at
the client. If that's not what you're looking for, a web app is not the
right technology for your situation. Consider a desktop application instead.
HtH
Imar
At 04:11 PM 4/17/2002 +0000, you wrote:
>Please note, I'm new to this type of web development, including ASP.NET
>and ASP. There are probably better ways to do some of what I'm doing, but
>I'm still learning. All advise and help is GREATLY appreciated!
>
>This is a scaled-down version of what I'm trying to do, I put **** around
>the area where I'm needing the pop-up window:
>
><%@ Import Namespace="System.Object" %>
><%@ Import Namespace="System.Data" %>
><%@ Import Namespace="System.Data.SqlClient" %>
><%@ Import Namespace="System.IO" %>
>
><script language="vb" runat="server">
>
> Sub Page_Load()
> ' first time through, assign variables, otherwise skip
> If Trim(Session("strIDSID")) = "" Then
> 'get full username and login id
> End If
> End Sub
>
> Function fnConnection(strDBName as String)
> 'assign variable the connection string
> 'find out which server is being used
> 'connect to database
> end Function
>
> Sub UploadFile(objSource As Object, objArgs As EventArgs)
> 'This procedure uploads user's file to the server and updates the
> 'tracking database with file ownership information.
> Dim strFullUpFileNm as String = MyFileInput.PostedFile.Filename
> Dim strUpFileNm as String
> Dim strUpFileSize as String = MyFileInput.PostedFile.ContentLength
> Dim strSaveAsNm as String
> Dim strUpFileExt as String
> Dim strSaveAsPath as String
> Dim objDataReader as SqlDataReader
>
> If (Trim(MyFileInput.PostedFile.Filename) <> "") Then
> 'Check to see if the file exists in the destination folder
> If System.IO.File.Exists(strSaveAsPath & strSaveAsNm) Then
> 'check database to see if user is file owner
> If Session("strWWID") = objDataReader.GetString(3) then
> Else
> 'someone else owns the file - display error message
> '*****************************************************************
> '*** have pop-up window display that someone else owns the file
> '*****************************************************************
> End If
> Else
> 'file is a new posting; need to add to db & upload file to server
> End IF
> Else
> 'error - upload filename is blank
> End If
> End Sub
>
></script>
>
><h2>Upload Files</h2>
><form id="Form1" enctype="multipart/form-data" runat="server">
> <table id="Table1" class="fontdefault" cellspacing="0" cellpadding="2">
> <tr valign="top">
> <td>Choose File to Upload
> <br><input type="file" id="MyFileInput" size="70" runat="server"
>NAME="MyFileInput">
> </td>
> </tr>
> <tr valign="top">
> <td width="50"> </td>
> <td>
> <asp:requiredfieldvalidator
> id="ReqFldFileInput"
> controltovalidate="MyFileInput"
> text="."
> initialvalue=""
> errormessage="* Input file not selected"
> runat="server"/>
> </td>
> </tr>
> <tr valign="top">
> <td>
> <input type="button" id="SubmitButton" value="Upload File"
> runat="server" onserverclick="UploadFile" NAME="SubmitButton">
> </td>
> </tr>
> <tr valign="top">
> <td><br />Upload Success Information<br />
> <textarea id="UpFileTextArea" rows="5" cols="65"
> runat="server" NAME="UpFileTextArea"></textarea>
> </td>
> </tr>
>
> </table>
> <br /><br />
> <asp:validationsummary
> id="ValidationSummary3"
> runat="server"
> DisplayMode="List"
> ShowMessageBox="True">
> </asp:validationsummary>
>
></form>
><div id="outError" runat="server"></div>
>
Message #14 by "Stephanie Patterson" <stephanie.l.patterson@i...> on Wed, 17 Apr 2002 17:46:06
|
|
Thank you, Imar!!!! I understand about the server vs. client, but I was
having trouble getting the compiler past the 'script' in the other
suggestions of the following:
Response.Write "<script language=""javascript"">" & vbCrLf
Response.Write " window.open(blah..blah..blah...);" & vbCrLf
Response.Write "</script>" & vbCrLf
But by breaking it apart into a string the way you did and using
response.write that string out it gives me the message box (I had to edit
it a bit for the quotes).
Dim sMessageBox as String
sMessageBox = "<scr" & "ipt language=""JavaScript""
type=""text/javascript"">" & vbCrlf
sMessageBox &= "alert('File is in use or whatever you want to show
here');"
sMessageBox &= "</scr" & "ipt>"
Response.Write(sMessageBox)
Thanks again, Imar!
Stephanie
Message #15 by "Peter Lawrence" <peter.lawrence@p...> on Wed, 17 Apr 2002 17:42:38 +0100
|
|
I think your issue is of understanding what the role of the VB code is -
basically it is generating an HTML stream which is then passed to the
browser, which then responds to it, including (in your case) popping up a
window. The server-side code cannot itself popup a window.
So your code needs to generate the HTML (including some javascript to popup
a window) and for it to be passed back to the browser before it will happen.
(Just seen Imar's post - I'm saying the same thing - but since I wrote this
already you can have a second opinion!).
Taking a slightly different approach, though, ... rather than a popup window
I tend to have a messages area at the top of each page defined like this....
<span id="msg" runat="server"></span>
If an error message needs to be passed back to the user, I set the message
as follows (using a bit of your code), then exit sub (to make sure nothing
else is done)...
'check database to see if user is file owner
If Session("strWWID") <> objDataReader.GetString(3) then
'someone else owns the file - display error message
msg.InnerHtml = "a message"
End If
Exit Sub
You'll get there!
Peter
----- Original Message -----
From: "Stephanie Patterson" <stephanie.l.patterson@i...>
To: "aspx_beginners" <aspx_beginners@p...>
Sent: Wednesday, April 17, 2002 4:11 PM
Subject: [aspx_beginners] RE: Popup window in ASP.NET?
> Please note, I'm new to this type of web development, including ASP.NET
> and ASP. There are probably better ways to do some of what I'm doing, but
> I'm still learning. All advise and help is GREATLY appreciated!
>
> This is a scaled-down version of what I'm trying to do, I put **** around
> the area where I'm needing the pop-up window:
>
> <%@ Import Namespace="System.Object" %>
> <%@ Import Namespace="System.Data" %>
> <%@ Import Namespace="System.Data.SqlClient" %>
> <%@ Import Namespace="System.IO" %>
>
> <script language="vb" runat="server">
>
> Sub Page_Load()
> ' first time through, assign variables, otherwise skip
> If Trim(Session("strIDSID")) = "" Then
> 'get full username and login id
> End If
> End Sub
>
> Function fnConnection(strDBName as String)
> 'assign variable the connection string
> 'find out which server is being used
> 'connect to database
> end Function
>
> Sub UploadFile(objSource As Object, objArgs As EventArgs)
> 'This procedure uploads user's file to the server and updates the
> 'tracking database with file ownership information.
> Dim strFullUpFileNm as String = MyFileInput.PostedFile.Filename
> Dim strUpFileNm as String
> Dim strUpFileSize as String = MyFileInput.PostedFile.ContentLength
> Dim strSaveAsNm as String
> Dim strUpFileExt as String
> Dim strSaveAsPath as String
> Dim objDataReader as SqlDataReader
>
> If (Trim(MyFileInput.PostedFile.Filename) <> "") Then
> 'Check to see if the file exists in the destination folder
> If System.IO.File.Exists(strSaveAsPath & strSaveAsNm) Then
> 'check database to see if user is file owner
> If Session("strWWID") = objDataReader.GetString(3) then
> Else
> 'someone else owns the file - display error message
>
'*****************************************************************
> '*** have pop-up window display that someone else owns the file
>
'*****************************************************************
> End If
> Else
> 'file is a new posting; need to add to db & upload file to server
> End IF
> Else
> 'error - upload filename is blank
> End If
> End Sub
>
> </script>
>
> <h2>Upload Files</h2>
> <form id="Form1" enctype="multipart/form-data" runat="server">
> <table id="Table1" class="fontdefault" cellspacing="0" cellpadding="2">
> <tr valign="top">
> <td>Choose File to Upload
> <br><input type="file" id="MyFileInput" size="70" runat="server"
> NAME="MyFileInput">
> </td>
> </tr>
> <tr valign="top">
> <td width="50"> </td>
> <td>
> <asp:requiredfieldvalidator
> id="ReqFldFileInput"
> controltovalidate="MyFileInput"
> text="."
> initialvalue=""
> errormessage="* Input file not selected"
> runat="server"/>
> </td>
> </tr>
> <tr valign="top">
> <td>
> <input type="button" id="SubmitButton" value="Upload File"
> runat="server" onserverclick="UploadFile" NAME="SubmitButton">
> </td>
> </tr>
> <tr valign="top">
> <td><br />Upload Success Information<br />
> <textarea id="UpFileTextArea" rows="5" cols="65"
> runat="server" NAME="UpFileTextArea"></textarea>
> </td>
> </tr>
>
> </table>
> <br /><br />
> <asp:validationsummary
> id="ValidationSummary3"
> runat="server"
> DisplayMode="List"
> ShowMessageBox="True">
> </asp:validationsummary>
>
> </form>
> <div id="outError" runat="server"></div>
>
>
Message #16 by "Datatal AB - Gauffin, Jonas" <Jonas@d...> on Wed, 17 Apr 2002 18:43:31 +0200
|
|
Hmm.. isnt this code a bit cleaner?
Public Function MessageBox(YourMessage) As String
MessageBox =3D "<script language=3D""JavaScript""
type=3D""text/javascript"">" & vbCrlf & _
"alert('" & YourMessage & "');" & vbcrlf & _
"</script>"
End Function
Response.Write(sMessageBox("Hello there"))
_ means that the code continues on the next line
> -----Original Message-----
> From: Stephanie Patterson [mailto:stephanie.l.patterson@i...]
> Sent: den 17 april 2002 19:46
> To: aspx_beginners
> Subject: [aspx_beginners] RE: Popup window in ASP.NET?
>
>
> Thank you, Imar!!!! I understand about the server vs.
> client, but I was
> having trouble getting the compiler past the 'script' in the other
> suggestions of the following:
>
> Response.Write "<script language=3D""javascript"">" & vbCrLf
> Response.Write " window.open(blah..blah..blah...);" & vbCrLf
> Response.Write "</script>" & vbCrLf
>
> But by breaking it apart into a string the way you did and using
> response.write that string out it gives me the message box (I
> had to edit
> it a bit for the quotes).
>
> Dim sMessageBox as String
> sMessageBox =3D "<scr" & "ipt language=3D""JavaScript""
> type=3D""text/javascript"">" & vbCrlf
> sMessageBox &=3D "alert('File is in use or whatever you want to show
> here');"
> sMessageBox &=3D "</scr" & "ipt>"
> Response.Write(sMessageBox)
>
> Thanks again, Imar!
> Stephanie
>
>
Message #17 by "Datatal AB - Gauffin, Jonas" <Jonas@d...> on Wed, 17 Apr 2002 18:44:44 +0200
|
|
oops. a typo.
Public Function MessageBox(YourMessage) As String
MessageBox =3D "<script language=3D""JavaScript""
type=3D""text/javascript"">" & vbCrlf & _
"alert('" & YourMessage & "');" & vbcrlf & _
"</script>"
End Function
Response.Write(MessageBox("Hello there"))
> -----Original Message-----
> From: Datatal AB - Gauffin, Jonas
> Sent: den 17 april 2002 18:44
> To: aspx_beginners
> Subject: [aspx_beginners] RE: Popup window in ASP.NET?
>
>
> Hmm.. isnt this code a bit cleaner?
>
> Public Function MessageBox(YourMessage) As String
>
> MessageBox =3D "<script language=3D""JavaScript""
> type=3D""text/javascript"">" & vbCrlf & _
> "alert('" & YourMessage & "');" & vbcrlf & _
> "</script>"
>
> End Function
>
> Response.Write(sMessageBox("Hello there"))
>
>
> _ means that the code continues on the next line
>
>
> > -----Original Message-----
> > From: Stephanie Patterson [mailto:stephanie.l.patterson@i...]
> > Sent: den 17 april 2002 19:46
> > To: aspx_beginners
> > Subject: [aspx_beginners] RE: Popup window in ASP.NET?
> >
> >
> > Thank you, Imar!!!! I understand about the server vs.
> > client, but I was
> > having trouble getting the compiler past the 'script' in the other
> > suggestions of the following:
> >
> > Response.Write "<script language=3D""javascript"">" & vbCrLf
> > Response.Write " window.open(blah..blah..blah...);" & vbCrLf
> > Response.Write "</script>" & vbCrLf
> >
> > But by breaking it apart into a string the way you did and using
> > response.write that string out it gives me the message box (I
> > had to edit
> > it a bit for the quotes).
> >
> > Dim sMessageBox as String
> > sMessageBox =3D "<scr" & "ipt language=3D""JavaScript""
> > type=3D""text/javascript"">" & vbCrlf
> > sMessageBox &=3D "alert('File is in use or whatever you
> want to show
> > here');"
> > sMessageBox &=3D "</scr" & "ipt>"
> > Response.Write(sMessageBox)
> >
> > Thanks again, Imar!
> > Stephanie
> >
> >
>
>
>
Message #18 by Imar Spaanjaars <Imar@S...> on Wed, 17 Apr 2002 18:49:42 +0200
|
|
The compiler while mistake the </script> for the client code with the end
tag of the server side code. That's why you need to break it apart.
Glad it worked out.
Imar
At 05:46 PM 4/17/2002 +0000, you wrote:
>Thank you, Imar!!!! I understand about the server vs. client, but I was
>having trouble getting the compiler past the 'script' in the other
>suggestions of the following:
>
> Response.Write "<script language=""javascript"">" & vbCrLf
> Response.Write " window.open(blah..blah..blah...);" & vbCrLf
> Response.Write "</script>" & vbCrLf
>
>But by breaking it apart into a string the way you did and using
>response.write that string out it gives me the message box (I had to edit
>it a bit for the quotes).
>
> Dim sMessageBox as String
> sMessageBox = "<scr" & "ipt language=""JavaScript""
>type=""text/javascript"">" & vbCrlf
> sMessageBox &= "alert('File is in use or whatever you want to show
>here');"
> sMessageBox &= "</scr" & "ipt>"
> Response.Write(sMessageBox)
>
>Thanks again, Imar!
>Stephanie
Message #19 by "Benjamin D. Gray" <bdgray@g...> on Wed, 17 Apr 2002 10:52:48 -0600
|
|
Does this work:
Sub UploadFile(objSource As Object, objArgs As EventArgs)
'This procedure uploads user's file to the server and updates the
'tracking database with file ownership information.
Dim strFullUpFileNm as String = MyFileInput.PostedFile.Filename
Dim strUpFileNm as String
Dim strUpFileSize as String = MyFileInput.PostedFile.ContentLength
Dim strSaveAsNm as String
Dim strUpFileExt as String
Dim strSaveAsPath as String
Dim objDataReader as SqlDataReader
If (Trim(MyFileInput.PostedFile.Filename) <> "") Then
'Check to see if the file exists in the destination folder
If System.IO.File.Exists(strSaveAsPath & strSaveAsNm) Then
'check database to see if user is file owner
If (Session("strWWID") <> objDataReader.GetString(3)) Then
'someone else owns the file - display error message
Dim sMessageBox as String
sMessageBox = "<scr" & "ipt language=""JavaScript"" "
sMessageBox &= "type=""text/javascript"">" & vbCrlf
sMessageBox &= "alert('Not your file or whatever');"
sMessageBox &= "</scr" & "ipt>"
Response.Write(sMessageBox)
End If
Else
'file is a new posting; need to add to db & upload file to
server
End IF
Else
'error - upload filename is blank
End If
End Sub
Benjamin D. Gray
WIND Web Developer
http://uwyo.edu/wind/
|
|
 |