| | |
Button to open a new browser window
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
One way is with a JScript function in the OnClick event for a button.
That help?
ASP.NET Syntax (Toggle Plain Text)
<form id="Form1"> <INPUT Type="button" OnClick="window.open('http://www.google.ca')" value="enter"> </form>
That help?
•
•
Join Date: Jun 2004
Posts: 32
Reputation:
Solved Threads: 1
sadly you have missed the point of asp.net
you are using traditional html tags which renders asp.net useless.
read up on server controls.
<form runat=server>
<asp:button id=button1 runat=server>
</form>
--
in the page load add:
button1 .Attributes.Add("onclick", "whatEverYouWantTheJavaSciptToDo");
i think this is right
if you wanna learn .net
buy ASP.NET for Beginners using c# from WROX
jack
www.ansariltd.com
you are using traditional html tags which renders asp.net useless.
read up on server controls.
<form runat=server>
<asp:button id=button1 runat=server>
</form>
--
in the page load add:
button1 .Attributes.Add("onclick", "whatEverYouWantTheJavaSciptToDo");
i think this is right
if you wanna learn .net
buy ASP.NET for Beginners using c# from WROX
jack
www.ansariltd.com
•
•
•
•
Originally Posted by jackster
you are using traditional html tags which renders asp.net useless.
read up on server controls.
Furthermore, you can control most standard html controls with ASP.NET, just give them an ID="" and runat="server" in their tag.
-Ryan Hoffman
.NET Specialist / Webmaster, Extended64.com.
Please do not email or PM me with support questions. Please direct them to the forums instead.
.NET Specialist / Webmaster, Extended64.com.
Please do not email or PM me with support questions. Please direct them to the forums instead.
•
•
•
•
Originally Posted by jackster
sadly you have missed the point of asp.net
you are using traditional html tags which renders asp.net useless.
read up on server controls.
<form runat=server>
<asp:button id=button1 runat=server>
</form>
--
in the page load add:
button1 .Attributes.Add("onclick", "whatEverYouWantTheJavaSciptToDo");
i think this is right
if you wanna learn .net
buy ASP.NET for Beginners using c# from WROX
jack
www.ansariltd.com
Actually I didn't think I missed the point. The question was simple and answered. No requirements were stated. And besides that
OnClick could have contained ="Load_NewPage()" which points to a Load_NewPage() function (or method) in the C# code behind. I just gave the suggestion as a general means of doing it.
But then again, he can use whatever method he wants!
Well, a new article on MSDN came out yesturday, titled Improving ASP.NET Performance, and I'll quote it:
---
Use Server Controls Where Appropriate
The HTTP protocol is stateless; however, server controls provide a rich programming model that manages state between page requests by using view state. Server controls require a fixed amount of processing to establish the control and all of its child controls. This makes server controls relatively expensive compared to HTML controls or possibly static text. Scenarios where server controls are expensive include the following:
When you do not need rich interaction, replace server controls with an inline representation of the user interface that you want to present. You might be able to replace a server control under the following conditions:
---
Now, if this doesn't illustrate what I've said, I'm not sure if anything could ;-).
---
Use Server Controls Where Appropriate
The HTTP protocol is stateless; however, server controls provide a rich programming model that manages state between page requests by using view state. Server controls require a fixed amount of processing to establish the control and all of its child controls. This makes server controls relatively expensive compared to HTML controls or possibly static text. Scenarios where server controls are expensive include the following:
- Large payload over low bandwidth. The more controls that you have on a page, the higher the network payload is. Therefore, multiple controls decreases the time to last byte (TTLB) and the time to first byte (TTFB) for the response that is sent to the client. When the bandwidth between client and server is limited, as is the case when a client uses a low-speed dial-up connection, pages that carry a large view state payload can significantly affect performance.
- View state overhead. View state is serialized and deserialized on the server. The CPU effort is proportional to the view state size. In addition to server controls that use view state, it is easy to programmatically add any object that can be serialized to the view state property. However, adding objects to the view state adds to the overhead. Other techniques such as storing, computed data or storing several copies of common data adds unnecessary overhead.
- Composite controls or large number of controls. Pages that have composite controls such as DataGrid may increase the footprint of the view state. Pages that have a large number of server controls also may increase the footprint of the view state. Where possible, consider the alternatives that are presented later in this section.
When you do not need rich interaction, replace server controls with an inline representation of the user interface that you want to present. You might be able to replace a server control under the following conditions:
- You do not need to retain state across postbacks.
- The data that appears in the control is static. For example, a label is static data.
- You do not need programmatic access to the control on the server-side.
- The control is displaying read-only data.
- The control is not needed during postback processing.
---
Now, if this doesn't illustrate what I've said, I'm not sure if anything could ;-).
-Ryan Hoffman
.NET Specialist / Webmaster, Extended64.com.
Please do not email or PM me with support questions. Please direct them to the forums instead.
.NET Specialist / Webmaster, Extended64.com.
Please do not email or PM me with support questions. Please direct them to the forums instead.
•
•
Join Date: Jan 2006
Posts: 275
Reputation:
Solved Threads: 11
without going into too much argument over html vs asp.net controls etc (and I also use asp.net controls sparingly) I think you all missed the point of the original question
haha
I took it as he wanted to know how to open a new window not the button click event. So in answer to the original question - to open a link in a new browser window you need to set "target=_blank". That is if you are using an anchor (or hyperlink if you insist on them - but i strongly suggest you try an html anchor and some css). Otherwise use the window functions in javascript if you are going that way.
hahaI took it as he wanted to know how to open a new window not the button click event. So in answer to the original question - to open a link in a new browser window you need to set "target=_blank". That is if you are using an anchor (or hyperlink if you insist on them - but i strongly suggest you try an html anchor and some css). Otherwise use the window functions in javascript if you are going that way.
![]() |
Similar Threads
- Open form on the same window (ASP)
- Open form in the same window (ASP.NET)
- How to display a HTML file (in browser window) from Java Program...? (Java)
Other Threads in the ASP.NET Forum
- Previous Thread: DataList Control
- Next Thread: ASP.Net gridview with drop down list
| Thread Tools | Search this Thread |
.net 3.5 activexcontrol ajax alltypeofvideos appliances asp asp.net bc30451 beginner bottomasp.net box browser businesslogiclayer button c# cac checkbox class click commonfunctions countryselector dataaccesslayer database datagrid datagridview datagridviewcheckbox datalist deployment development dgv dialog dropdownlist dropdownmenu dynamic dynamically edit embeddingactivexcontrol fileuploader fill findcontrol flash formatdecimal formview gridview gudi iis javascript list listbox microsoft mono mouse mssql nameisnotdeclared news novell numerical opera panelmasterpagebuttoncontrols problem radio redirect registration relationaldatabases reportemail save schoolproject search security sessionvariables silverlight smartcard smoobjects software sql sql-server sqlserver2005 ssl suse textbox tracking treeview unauthorized validatedate validation vb.net video videos vista visualstudio vs2008 web webapplications webdevelopemnt webdevelopment webprogramming webservice xsl youareanotmemberofthedebuggerusers





