all groups > visual studio .net general > march 2006 >
You're in the

visual studio .net general

group:

Opening new browser from Code


Opening new browser from Code Ashhad Syed
3/31/2006 9:32:01 PM
visual studio .net general: Hello I am new to VS2003 .NET development and therefore have a really simple
question:

How do you open a new browser (without browser buttons and menu on top)
from within the code (I am using VB)?

I know you can use Respose.Redirect command to go to a different form in the
same browser.

ALso if the application tries to open a new browser will it be blocked by
popup blockers?

Thanks,
Ashhad.
Re: Opening new browser from Code Kevin Spencer
4/1/2006 10:15:45 AM
[quoted text, click to view]

How do you know it's simple, if you don't know the answer to it?

In fact, the answer is not simple at all.

[quoted text, click to view]

You use JavaScript. ASP.Net is all about HTML, and that includes CSS and
JavaScript, and may include quite a number of other languages and
technologies. An ASP.Net page generally (but not always) generates an HTML
document which is received by a client web browser that has made a request
for that document. In other words, ASP.Net is a client-server technology,
which encompasses the use of quite a number of other technologies, all of
which you will need to at least acquaint yourself with.

To open a new client-side browser without browser buttons and menu on top is
hardly a "simple" exercise. As HTTP (the Internet protocol which is employed
for client-server communications in ASP.Net) is a request/response protocol,
it cannot be done from the server. You may have noticed that you can't
access an ASP.Net web site (or any other web site) without opening your web
browser *first*. You open the browser, and type in a URL, or click a link
(etc), which sends an HTTP request to a web server, and the server responds
with an HTML document which is loaded into the browser.

Therefore, opening a new browser window on the client is not something that
can be done from the server. That's where JavaScript comes in. JavaScript is
a client-side scripting language used in HTML documents to perform various
client-side functions. The JavaScript window.open method is used to open a
new window. It can also be done with a hyperlink having a "target" attribute
of "_blank" (which instructs the browser to launch another instance and load
the document into it), but then you have no control over the new browser
window. To have control over the new window, you use the JavaScript
window.open method. You can read about it here:

http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/open_0.asp?frame=true

Of course, the script must be embedded in the HTML document. How it ends up
there depends on the details of why and how you're opening the window. It
can simply, like any HTML in an ASP.Net page, be in the Template, or you can
dynamically add the script to the page.

[quoted text, click to view]

If using the JavaScript window.open method, yes, it can.

Simple, eh?

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.


[quoted text, click to view]

Re: Opening new browser from Code Ashhad Syed
4/1/2006 4:39:01 PM
Kevin:

Thanks for the reply. The reason I thought it would be simple is because I
have seen it on many websites. In terms of what I am trying to accomplish, I
am opening a detailed record from a grid where I will perform some operation
on the record. The way I am opening the record is from a button column.

I guess the next best thing would be to open a browser with the controls and
file using a hyperlink.

Let me know if you have any other suggestions.

Thanks,
Ashhad.

[quoted text, click to view]
Re: Opening new browser from Code Kevin Spencer
4/2/2006 12:00:00 AM
Hi Ashhad,

[quoted text, click to view]

Well, it all depends on your app's requirements. In other words, what
requirement, in terms of functionality, did you come up with the solution of
opening a new browser window with no control in order to fulfill? There are
many ways to skin the proverbial cat. Perhaps I can help you think of
another solution which is more in keeping with a web interface.

I hope I didn't discourage you. Web application development is one of the
hardest kinds of development there is, due to the environment of HTTP, and
the fact that a web application is a multi-user client-server application.
It requires a lot more understanding than any other form of application
development that I know of, and the GUI tools in Visual Studio (or any other
development environment) will never be a substitute for understanding the
various technologies involved. However, that doesn't mean that it is not a
very rewarding type of development, or that one has to understand all of it
before one can begin. It simply means that you should be aware of these
technologies, protocols, and the environment, and learn about them as you
go. It is much easier today to learn about these things than it was a dozen
years ago when I began to work with web sites. Today, you have Google, and a
wealth of online information services to use as references and resources.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.

[quoted text, click to view]

AddThis Social Bookmark Button