window.open

  • Thread starter Thread starter Guy Cohen
  • Start date Start date
G

Guy Cohen

Hi all

How do I show an existing aspx page to the user?
I need an equivalent command to java's window.open in ASP.NET

TIA
Guy
 
How do I show an existing aspx page to the user?

Ordinarily, you would simply navigate to the page and it would display in
the browser...
I need an equivalent command to java's window.open in ASP.NET

If you need to open a second browser instance, you would need to use the
client-side JavaScript window.open method.
 
Thanks Mark.
To solve my problem I used a link button :)

If I cannot open a window using vb.net code and I cannot ask
questions/present messages using vb.net code....
Why should I use .NET technology then ?
............................................
 
To solve my problem I used a link button :)

There you go!
If I cannot open a window using vb.net code and I cannot ask
questions/present messages using vb.net code....

??? I think you have a fundamental misunderstanding of the ASP.NET paradigm.

Server-side code (VB.NET, C#, J# or whatever) has two principal functions:

1) to render client-side markup (HTML) and code (JavaScript) dynamically at
runtime (that's the "Active" bit in "Active Server Pages") and stream it
down to the browser;

2) to interact with the rest of the network's resources e.g. SQL Server (or
whatever RDBMS), Exchange Server, ActiveDirectory etc etc

Once the server-side processing has been completed and the page streamed
down to the browser, ASP.NET knows nothing further about what happens on
that browser until it receives another HttpRequest from it.

Opening a (new) window or asking the user a question are both client-side
functions so, by definition, they're not handled by VB.NET because that runs
server-side. However, as previously mentioned, there's nothing to stop
VB.NET creating the client-side mechanism for opening a new window or asking
a question. A very common use of this is asking the user to confirm whether
they want to perform an action, e.g. to delete a record.

Let's say you have an <asp:Button> web control as follows:

<asp:Button ID="MyDeleteButton" runat="server" Text="Delete"
OnClick="MyDeleteButton_Click" ToolTip="Delete the current record" />

Clicking this button would cause the page to post back to the server and
(eventually) run the MyDeleteButton_Click method in your server-side code.

However, if you want to ask the user to confirm whether they really want to
delete the record, you would do the following in your page's Page_Load
method:

MyDeleteButton.Attributes.Add("onclick", "return confirm('Are you sure you
want to delete this record?');)

Now, then the user clicks the Delete button, they will be presented with the
standard JavaScript confirm dialog. If they click "Cancel", nothing will
happen - the page will not post back and the server-side code will not run.
If they click OK, then the page will post back, and the server-side code
will run.
Why should I use .NET technology then ?

You don't have to use .NET technology if you don't want to...
 
If you want to pop up a window, you an create the JavaScript and feed it
from your code behind. If the same page opens every time, you use straight
JavaScript.

To have a client side command in server side code mixes metaphors. There is
nothing inherently wrong with it, but when the concepts of client side
script and server side code are blurred, you can end up with some strange
results if you do not understand where the line is. From my experience, a
great number of web developers do not understand the line and screw things
up, so I prefer a model that forces you to emit client side script, at least
until we have a more uniform model. It makes my job of fixing code a lot
easier. :-)

As for your question :
If I cannot open a window using vb.net code and I cannot ask
questions/present messages using vb.net code....
Why should I use .NET technology then ?

Different tools for different uses. Each has its strengths and it's
weaknesses.

But let me put this in perspective. If it sucks at screwing in screws, why
should I use a hammer? :-)

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com

*************************************************
Think outside of the box!
*************************************************
 
Back
Top