how can open a new page in a new tab

Posted by Bhuwan87rawat under ASP.NET on 3/13/2013 | Points: 10 | Views : 17406 | Status : [Member] | Replies : 5
hello sir
In my application i make a form which have some text like
Broker Login id,password ,and invester login id
and submit and cancel button
if user fill all value are correct the new page open in new tag other wise if user fill all incorrect value the page not open new tag its open same page




Responses

Posted by: Santhi on: 3/13/2013 [Member] Starter | Points: 25

Up
0
Down
Hi

To open a page on a new tab

Just try this code:
OnClientClickEvent of a button call the javascript method
And add the following the code:
 <script type="text/javascript">

function fun() {

window.open("Default4.aspx",'_blank');
}
</script>


    <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="fun()" />


Thanks & Regards,
Santhi .V

Bhuwan87rawat, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bhuwan87rawat on: 3/13/2013 [Member] Starter | Points: 25

Up
0
Down
sir i already apply this code but if user fill all wrong value then click submit button then same page open in same tab ,not in another tab
and if all value in right then open new tab

Bhuwan87rawat, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Santhi on: 3/13/2013 [Member] Starter | Points: 25

Up
0
Down
Hi

I implemented this.
Try this sample example:
You will get it.
Design page:
<head runat="server">

<script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>

<title></title>
<script type="text/javascript">
function fun() {

window.open("Default4.aspx",'_blank');
return false;
}
function Wrong() {
window.location.href("Default5.aspx");
return false;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:Label ID="Label1" runat="server" Text="Name"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<p>
<asp:Label ID="Label2"
runat="server" Text="ID"></asp:Label>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</p>
<p>
<asp:Button ID="Button1" runat="server" Text="LogIN"
onclick="Button1_Click" />

</p>

</form>
</body>


Cs page:

protected void Button1_Click(object sender, EventArgs e)

{
if((TextBox1.Text =="Name") && (TextBox2.Text=="1001"))
{
System.Web.UI.ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "Script", "fun();", true);
}
else
{
System.Web.UI.ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "Script", "Wrong();", true);
}
}


Thanks & Regards,
Santhi .V

Bhuwan87rawat, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Santhi on: 3/13/2013 [Member] Starter | Points: 25

Up
0
Down
Hi

just write those two javascript methods on aspx page.
and call those methods from the code behind based on the conditions.
To open a page in new tab.

Window.Open("URL");

To open a page on the same tab.
Window.location.href("URL)";

Return false


Thanks & Regards,
Santhi .V

Bhuwan87rawat, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jayakumars on: 3/13/2013 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi

try this code

protected void Bt_Submit_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(strConnString);
con.Open();
str = "Select * from Table_3 where EmpId="+ Convert.ToInt32(TxtEmpID.Text) +"";
com = new SqlCommand(str, con);
sqlda = new SqlDataAdapter(com);
ds = new DataSet();
sqlda.Fill(ds, "student");
if (ds.Tables[0].Rows.Count > 0)
{
lblErrMsg.Text = " This User Valid User!..";
}
else{
lblErrMsg.Text = " This User InValid User!..";
}
}

Mark as Answer if its helpful to you

Bhuwan87rawat, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response