Indeed you have to do use client-side code, but you actually can generate that code from server-side, al you have to do is append this code to Page.Load event handler of your ASP.NET web form.
What I do in this code is to generate the actual client side script line by line using a StringBuilder for concatenation, then I have all the script code rendered in the client HTML (immediately below the opening tag of the Page object’s <form runat=â€serverâ€> ) when the page loads using the RegisterClientScriptBlock.
Then, using the button's Attributes collection, I map the onclick client event of the ASP.NET button to the name of the script I previously generated.
This will cause you ASP.NET button to respond to the onclick client-side event by opening a new browser window, you can customize the new browser window, in my case i did it like a popup, so that I can append some parameters to the query string.
Hope this helps,
Alan Ferrandiz
MCT;MCDBA,MCSD for .NET
MSF Practitioner
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim oStringBuilder As New System.Text.StringBuilder()
oStringBuilder.Append("<SCRIPT language=""javascript"">")
oStringBuilder.Append(vbNewLine)
oStringBuilder.Append(" <!--")
oStringBuilder.Append(vbNewLine)
oStringBuilder.Append(" function popup(url) {")
oStringBuilder.Append(vbNewLine)
oStringBuilder.Append(" newwindow = window.open(url,'name','height=300,width=450,scrollbars=no');")
oStringBuilder.Append(vbNewLine)
oStringBuilder.Append(" if (window.focus) {newwindow.focus()}")
oStringBuilder.Append(vbNewLine)
oStringBuilder.Append(" return false;")
oStringBuilder.Append(vbNewLine)
oStringBuilder.Append(" }")
oStringBuilder.Append(vbNewLine)
oStringBuilder.Append(" //-->")
oStringBuilder.Append(vbNewLine)
oStringBuilder.Append("</SCRIPT>")
Page.RegisterClientScriptBlock("popup", oStringBuilder.ToString)
Button1.Attributes.Add("onClick", "return popup('popup.aspx?value=somevalue');")
End Sub