I have a LinkButton in masterpage and on click of LinkButton , I am redirecting to, say, Page1.aspx . On Page1.aspx , I have a button1. On click of that button1, I am opening new window, not affecting data of the Page1.aspx.
But when I click on LinkButton of masterpage, redirecting to Page1.aspx and from code behind,clicking button1 , Page1.aspx 's data gets changed.
How to prevent this. I am providing my code.
LinkButton on Masterpage :
<asp:LinkButton ID="lnkAppointMent" runat="server" OnClick="lnkAppointMent_Click"><span>Appointment Scheduler </span></asp:LinkButton>
click Event of LinkButton :
protected void lnkAppointMent_Click(object sender, EventArgs e)
{
Session["PhoneCenter"] = "Appointment";
Response.Redirect("PhoneMessage.aspx");
}
PageLoad of redirecting page(PhoneMessage.aspx) :
protected void Page_Load(object sender, EventArgs e)
{
fillCustomTypeMessages();
if (!Page.IsPostBack)
{
.
.
.
else if (Session["PhoneCenter"].ToString() == "Appointment")
{
btnScheduleAppointments_Click(btnScheduleAppointments, null);
}
.
.
.
Button on PhoneMessage.aspx :
<div style="float: right; padding-right: 120px">
<asp:Button ID="btnScheduleAppointments" runat="server" OnClick="btnScheduleAppointments_Click"
CssClass="button" Text="Schedule Appointments" ToolTip="Open appointment scheduler" />
</div>
RaisPostBack method on PhoneMessage.aspx :
protected override void RaisePostBackEvent(IPostBackEventHandler source, string eventArgument)
{
try
{
base.RaisePostBackEvent(source, eventArgument);
}
catch (Exception ex)
{
}
.
.
p.s : when I click on btnScheduleAppointment , source will be Schedule Appointments and if I click on lnkAppointMent , source will be <span>Appointment Scheduler </span> even if I am calling btnScheduleAppointment on click of lnkAppointMent.
Click event of button :
protected void btnScheduleAppointments_Click(object sender, EventArgs e)
{
if (!Permissions.checkPermissions(Session["employeeloggedin"].ToString(), "PHMSGVMD"))
{
ScriptManager.RegisterStartupScript(this, Page.GetType(), "OnLoad", "alert('You must have the Phone Messages: View and Modify permission to schedule appointments!')", true);
}
else
{
string script = String.Format("openNewWin('" + "phonescheduler.aspx" + "')");
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "openNewWin", script, true);
}
}
Script :
function openNewWin(url)
{
alert(url);
var open_link = window.open('', '_blank');
open_link.location = url;
}
Any clarification needed. Please comment.


