response.write target _blank messes up sending page format

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
7/1/2008 9:20:10 AM
Gravatar
Total Posts 112

response.write target _blank messes up sending page format

Hi All;

I have a Module where I push a button and get a target page using Response.Redirect  without problems, but I would like it to create the target in a new window as might be done by 'target="_blank"'. So I've implemented the Response.Write-s seen in comments, below; which functions, except that the sending page formatting is messed up after I've pushed the button. (Oh yea, I pull the Response.Redirect when using the Response.Write-s.)

protected void SummaryButton_Click(object sender, EventArgs e)
{
// TODO Open in new page like target=_blank;
/*
// This works, but the sending page formatting gets messed up.
Response.Write("<script>");
Response.Write("window.open('Modules/MasterSummary.aspx','_blank')");
Response.Write("</script>");
*/
Response.Redirect ("Modules/MasterSummary.aspx");
}

Any suggestions are very much appreciated,
Dale E. Moore
 

7/1/2008 1:22:05 PM
Gravatar
Total Posts 18439

Re: response.write target _blank messes up sending page format

Hi Dale,

This isn't Classic ASP. You can't just response.write stuff in button click events and expect things to work right.

The right way to do it is to just use a link.

<asp:HyperLink ID="lnkDetails" runat="server" />

In code you can make the link open a new window by setting it up like this:

lnkDetails.Text = "Your link text";
lnkDetails.NavigateUrl = "yourdetailspageurl.aspx";
lnkDetails.Attributes.Add("onclick", "window.open(this.href,'_blank');return false;");

Note that using the onclick and javascript to open the page in a new window is preferrable to using the target attribute because target is not a valid attribute in xhtml

Hope it helps,

Joe

7/2/2008 10:01:34 AM
Gravatar
Total Posts 112

Re: response.write target _blank messes up sending page format

Dear Joe;

Your suggestion worked perfectly!

Thanks for your wider explaination; I very much appreciate your guidance!
Dale E. Moore

You must sign in to post in the forums. This thread is closed to new posts.