Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Sir m having a dought in my real estate website there is Featured property page in which all the listed property is displayed and view detail button below every property. I opened the detail page in new tab in the same browser on button click for every property.But when close all the tab and refresh the featured property page last property which i opened is opening automatically in new tab.

m using the folowing code.

onitemcommand in datalist

C#
protected void Datalist1_ItemCommand(object sender, DataListCommandEventArgs e)
    {
        switch (e.CommandName)
        {
           string strJS = ("<script type='text/javascript'>window.open('ViewDetail.aspx?Property_ID=" + e.CommandArgument.ToString() + "','_blank');</script>");
                Page.ClientScript.RegisterStartupScript(this.GetType(), "strJSAlert", strJS);                
        }
}



Button design
HTML
<asp:Button class="btndetail" ID="btndetails" CommandName="viewdetail" CommandArgument='<%#DataBinder.Eval(Container.DataItem,"Property_ID") %>' runat="server"  Text="ViewDetails" />



this is how m binding data in my detail page
C#
protected void Page_Load(object sender, EventArgs e)
   {
       if (!IsPostBack)
       {
           Session["Property_ID"] = Request.QueryString["Property_ID"].ToString();
           Displaydetails(Request.QueryString["Property_ID"].ToString());
       }
   }

   private void Displaydetails(string Property_ID)
   {
       int PropertyID = Convert.ToInt16(Property_ID);
       try
       {
           SqlConnection con = new SqlConnection(str);
           string strQ = ("select s.Property_ID,s.Property_For,s.Property_Type,s.Property_Name,C.City_Name,L.Locality_Name,s.Price,s.Bedroom,s.Area,s.ImageName,s.ImagePath,s.Address,s.Pincode,s.Key_Features,s.Date_Posted From tbl_Post_Property as s inner join tbl_City as C on C.City_Id=s.City_id inner join tbl_Locality as L on L.Locality_Id=s.Locality_Id where Property_ID=" + PropertyID + "");
           con.Open();
           SqlDataAdapter da = new SqlDataAdapter(strQ, con);
           DataTable dt = new DataTable();
           da.Fill(dt);
           PropDetail.DataSource = dt;
           PropDetail.DataBind();


       }
       catch (Exception ex)
       {

       }


   }
Posted
Updated 25-Oct-12 22:03pm
v4

1 solution

That isn't something that is under your control. The user's configuration will define whether a new tab or a new window gets opened for this action.
 
Share this answer
 
Comments
Raj.Rautela 25-Oct-12 13:46pm    
but if i want to open in new tab in my browser just for testing purpose what should do..
Sergey Alexandrovich Kryukov 25-Oct-12 15:01pm    
"I want" does not govern the World... :-)
--SA
Sergey Alexandrovich Kryukov 25-Oct-12 15:01pm    
This is the way it is. My 5.
--SA
Raj.Rautela 26-Oct-12 1:10am    
sir i know what u r saying..but it is the requirement of client pls tell me any solution if possible how we can achieve this.open page in new window or new tab..
fjdiewornncalwe 26-Oct-12 8:46am    
Clearly, you don't know what I'm saying. You CANNOT control this, so you have to tell your client that this is the case.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900