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
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
<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
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)
{
}
}