This is a migrated thread and some comments may be shown as answers.

PageRequestManagerServerErrorException with javascript newline characters

1 Answer 53 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Joey
Top achievements
Rank 1
Joey asked on 26 Aug 2009, 06:48 PM
I'm getting a "Sys.WebForms.PageRequestManagerServerErrorException: Object reference not set to an instance of an object" error and I know why but I just don't know how to resolve it.

I've got a page with a RadGrid on it and in the ItemDataBound event I add a confirmation dialog to a column that contains a button as shown below and the reason for the above error is the use of the newline character in the javascript. I've tried using three and four backslashes just for giggles and it produces the same error. I've also tried wrapping the entire RadGrid in a RadScriptBlock and a RadCodeBlock but neither have any affect on the error.

How do I use the new line character in my confirmation dialog and prevent the above error?

                Button executeButton = dataItem["clmExecute"].Controls[0] as Button;
                if (executeButton != null)
                    executeButton.Attributes["onclick"] = string.Format("if(!confirm('Confirm that you want to execute the selected step(s) to:\\n\\nDeployment Date: {0}\\nDescription: {1}\\nRegion: {2}\\nEnvironment: {3}\\n')){{return false;}}", _master.DeploymentDate.ToShortDateString(), _master.DeploymentDateDescription, _master.Region, _master.Environment);

1 Answer, 1 is accepted

Sort by
0
Joey
Top achievements
Rank 1
answered on 26 Aug 2009, 08:16 PM
Please delete this post. Turned out to be a server side null reference and had nothing to do with the javascript newline...
Tags
Ajax
Asked by
Joey
Top achievements
Rank 1
Answers by
Joey
Top achievements
Rank 1
Share this question
or