Jump to content
Software FX Community

Response.Redirect cannot be called in a Page callback.


jvwiv
 Share

Recommended Posts

Guys,

I've gotten really far along in development of my app, getting ready for final testing and deployment to production.  Thanks for all the help along the way.  I have one final hurdle to overcome.  I need to be able to click on a button on the grid that then prints a SRS report based upon the invoice number in the grid.  When I attempt the following line of code I get the error message Response.Redirect cannot be called in a Page callback. 

Here's my code... (located in Grid1.executingcustomcommand)

dim msg as string

msg = "Http://sqlserver01/reportserver?/MarinaReports/SalesOrder&SalesOrderID=" + cstr(e.gridItem.datavalues.primaryKey.tostring()) + "&rs:Format=pdf&rs:command=Render"

response.redirect(msg)

 

How can I accomplish this feat with your GridFX?

 

ChartFx_ItemSource Fail.zip

Link to comment
Share on other sites

As you found out, ASP.NET doesn't allow response.redirects in callbacks.  At this time, the custom command always uses callbacks, although a postback option will be added in the future.  Instead of using CommandButton, I would recommend using a regular Button control in a TemplateColumn, then handle its Click event.

Add a template column, edit its template, drag a button, and handle the button's click event in the property grid.  The markup will look something like

<GridFX:TemplateColumn>

<HeaderTemplate>

Header Template

</HeaderTemplate>

<ItemTemplate><asp:Button ID="Button1" runat="server" onclick="Button1_Click"

Text="View Report" />

</ItemTemplate>

</GridFX:TemplateColumn>

An event handler will be created.  In that handler, you need to get the GridItem that contains the button via the static GridItem.FindContainingItem method.  Then you can do the rest of what you need and Response.Redirect will work great.  Here's a quick C# handler:

protected void Button1_Click(object sender, EventArgs e)

{

GridItem item = GridItem.FindContainingItem((Control)sender);string link = "http://header" + item.DataValues.PrimaryKey.ToString() + "footer";

Response.Redirect(link);

 

}

Hope this helps.  Let me know how it goes.

Link to comment
Share on other sites

Stephan, Thanks for the update.  As my .Net developer is on vac for the next 2 weeks, could you convert the code to VB.net for me?  Also, I updated the grid to include an asp:imagebutton successfully, but don't see the onclick event.  Where would I find that?

John

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...