Linkbutton, Target="_blank"
-
Hey, I have a couple of link buttons and I am trying to get them to open a page in a new window. I know how to do this with a normal link, but I also have some very simple code behind that I need to run (Set a session variable). I've tried to add attributes to the linkbutton by doing
lnkBtnEnterprise.Attributes.Add("Target", "_blank");
but that doesnt seem to do anything. Let me know if you have any suggestions. Thanks for your time.protected void lnkBtnEnterprise_Click(object sender, EventArgs e)
{
lnkBtnEnterprise.Attributes.Add("Target", "_blank");
Session["Owner"] = 1;
Response.Redirect("~/SampleDashboardDetails.aspx");
}JM
-
Hey, I have a couple of link buttons and I am trying to get them to open a page in a new window. I know how to do this with a normal link, but I also have some very simple code behind that I need to run (Set a session variable). I've tried to add attributes to the linkbutton by doing
lnkBtnEnterprise.Attributes.Add("Target", "_blank");
but that doesnt seem to do anything. Let me know if you have any suggestions. Thanks for your time.protected void lnkBtnEnterprise_Click(object sender, EventArgs e)
{
lnkBtnEnterprise.Attributes.Add("Target", "_blank");
Session["Owner"] = 1;
Response.Redirect("~/SampleDashboardDetails.aspx");
}JM
-
Hey, I have a couple of link buttons and I am trying to get them to open a page in a new window. I know how to do this with a normal link, but I also have some very simple code behind that I need to run (Set a session variable). I've tried to add attributes to the linkbutton by doing
lnkBtnEnterprise.Attributes.Add("Target", "_blank");
but that doesnt seem to do anything. Let me know if you have any suggestions. Thanks for your time.protected void lnkBtnEnterprise_Click(object sender, EventArgs e)
{
lnkBtnEnterprise.Attributes.Add("Target", "_blank");
Session["Owner"] = 1;
Response.Redirect("~/SampleDashboardDetails.aspx");
}JM
First, this won't do anything for you. You are applying an attribute to the link then immediately redirecting to another page. Second, attributes are case sensitive, target should be lowercase.
only two letters away from being an asset
-
Hey, I have a couple of link buttons and I am trying to get them to open a page in a new window. I know how to do this with a normal link, but I also have some very simple code behind that I need to run (Set a session variable). I've tried to add attributes to the linkbutton by doing
lnkBtnEnterprise.Attributes.Add("Target", "_blank");
but that doesnt seem to do anything. Let me know if you have any suggestions. Thanks for your time.protected void lnkBtnEnterprise_Click(object sender, EventArgs e)
{
lnkBtnEnterprise.Attributes.Add("Target", "_blank");
Session["Owner"] = 1;
Response.Redirect("~/SampleDashboardDetails.aspx");
}JM
-
Yes, it is ASP.NET. I was trying to open the page using C# and w/o javascript. I've spent all day trying to figure it out to no avail. When I do the
lnkBtnEnterprise.Attributes.Add("target", "_blank");
and click the button on the page, I get an error of "Microsoft JScript runtime error: Object expected" -
Yes, it is ASP.NET. I was trying to open the page using C# and w/o javascript. I've spent all day trying to figure it out to no avail. When I do the
lnkBtnEnterprise.Attributes.Add("target", "_blank");
and click the button on the page, I get an error of "Microsoft JScript runtime error: Object expected"WE have an ASP.NET forum. Posting in the C# forum leaves people trying to figure out if you're writing a web app, which is often less obvious than it was in this case.
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
-
WE have an ASP.NET forum. Posting in the C# forum leaves people trying to figure out if you're writing a web app, which is often less obvious than it was in this case.
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
-
OK, but its a C#.Net question, is it not? Thats why I thought this forum was more appropriate.
The code might be in C# but the concepts are either Web Development or ASP.Net, either of which would, in my opinion, be better homes for your question.
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
-
The code might be in C# but the concepts are either Web Development or ASP.Net, either of which would, in my opinion, be better homes for your question.
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
-
:omg: :wtf: Seriously, WTF. Session, Response??? This doesn't give you a clue??
only two letters away from being an asset
-
:omg: :wtf: Seriously, WTF. Session, Response??? This doesn't give you a clue??
only two letters away from being an asset
-
:omg: :wtf: Seriously, WTF. Session, Response??? This doesn't give you a clue??
only two letters away from being an asset
-
I found a solution. I ended up changing the link buttons to links and passed a variable through the link, then grabbed the variable and stored it to the session variable I was using in a Page_PreInit function. Send it from first page: Receive on second page:
protected void Page_PreInit(Object sender, EventArgs e)
{
Session["Owner"] = Request.QueryString["Owner"];
}Thanks for your help guys.
-
I found a solution. I ended up changing the link buttons to links and passed a variable through the link, then grabbed the variable and stored it to the session variable I was using in a Page_PreInit function. Send it from first page: Receive on second page:
protected void Page_PreInit(Object sender, EventArgs e)
{
Session["Owner"] = Request.QueryString["Owner"];
}Thanks for your help guys.
<asp:LinkButton ID="lbtnValidRules" runat="server" Text="Validation Rules" OnClientClick="window.open('ValidationRules.aspx', 'ValidRules', 'width=1100,height=800,status=yes'); return false;">
</asp:LinkButton>this is how I do