Dim sb As System.Text.StringBuilder = New System.Text.StringBuilder()
sb.Append("<script language='javascript'>")
sb.Append("window.open('webapp.aspx', '', 'resizable=yes, menubar=no, toolbar=no, status=no, location=no, channelmode=yes')<")
sb.Append("/script>")
If Not ClientScript.IsClientScriptBlockRegistered(Me.GetType(), "PopupScript") Then
ClientScript.RegisterClientScriptBlock(Me.GetType(), "openPopUp", sb.ToString())
'ClientScript.RegisterStartupScript(Me.GetType(), "openPopUp", sb.ToString())
'Response.Write(sb.ToString())
End If
codebehind
Dim url As String = "~/webapp.aspx"
ClientScript.RegisterStartupScript(Me.GetType(), "openwin", "<script>openPopUp2('" & url & "')</script>")
aspx
function openPopUp2(url) {
alert('hi');
window.open(url, "", " resizable=yes, menubar=no, toolbar=no, status=no, location=no, channelmode=yes");
}
ASKER
ASKER
ASKER
ASKER
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
' Asuming that your user have valid credentials...
FormsAuthentication.SetAuthCookie("MyUserName", False)
' Then this will call your openPopUp2 javascript function when the page is loaded, so webapp.aspx will be open in a new window.
' Note that a popup blocker can block this action.
Dim myUrl As String = "webapp.aspx"
ScriptManager.RegisterStartupScript(Me, Me.GetType(), "openPopUp2", "openPopUp2('" + myUrl + "');", True)
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
function openPopUp2(url) {
window.open(url, "", "resizable=yes, menubar=no, toolbar=no, status=no, location=no, channelmode=yes");
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Validate User" />
</div>
</form>
</body>
</html>
ASKER
<asp:Login ID="LoginUser" runat="server" EnableViewState="false" RenderOuterTable="false"
DisplayRememberMe="false" OnLoggedIn="loginRedirect" RememberMeSet="false" >
Protected Sub loginRedirect(ByVal sender As Object, ByVal e As EventArgs)
FormsAuthentication.SetAuthCookie(sUserName, False)
Dim url As String = "mywebapp.aspx"
ScriptManager.RegisterStartupScript(Me, Me.GetType(), "openPopUp2", "openPopUp2('" + url + "');", True) 'this goes straight to logout page
Response.Redirect(url) 'this works... just doesn't open a new window
End Sub
Protected Sub loginRedirect(ByVal sender As Object, ByVal e As EventArgs)
FormsAuthentication.SetAuthCookie(sUserName, False)
Dim url As String = "mywebapp.aspx"
ScriptManager.RegisterStartupScript(Me, Me.GetType(), "openPopUp2", "openPopUp2('" + url + "');", True) 'this goes straight to logout page
End Sub
ASKER
ASKER
The successor to Active Server Pages, ASP.NET websites utilize the .NET framework to produce dynamic, data and content-driven web applications and services. ASP.NET code can be written using any .NET supported language. As of 2009, ASP.NET can also apply the Model-View-Controller (MVC) pattern to web applications
TRUSTED BY