Buttons, Textboxs and hyperlinks

  • Thread starter Thread starter Tom Rebbettes
  • Start date Start date
T

Tom Rebbettes

could anybody help me out with some code.. basically what
i need is that when a user presses a Web Button the
browser will open a new window for the url they typed in
or was already present in TextBox1.

Im using VisualStudios.NET 2003 c#

thanks

Tom
 
You'd need javascript for that. Consider Button1 click event
Response.Write("<script>window.open('newpagehere.aspx','arbitrarywindowname'
)</script>");
window.open takes a bunch of parameters to help you customize the look and
feel of the child window.

If you supply a window name, the child window will always use this window so
you can have at most one child window. If you want to generate new windows
on each click you have to make the window name unique. You can use the
following code to get the desired effect.

Page.Controls.Add(new LiteralControl("<script>window.open('Export.aspx',
'"+System.Text.RegularExpressions.Regex.Replace(DateTime.Now.ToString(),"\\D
","")+"', 'toolbar=no,scrollbars=yes,width=" + width + ",height=" + height +
",resizable=yes')</script>"));

Page.Controls.Add and Response.Write provide the same effect here and can be
merily interchanged without side effect.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top