The Temple of Fu

code, systems and games

Archive for the ‘ASP.Net’ Category

Procedure or function X expects parameter Y, which was not supplied.

with 3 comments

I have been tracking down the source of this error for about an hour and a half.

“Procedure or function ‘procedure name’ expects parameter ‘@parameter_name’, which was not supplied.”

This is happening when I call a stored procedure with parameters through .Net’s data connection to SQL ( and also through a WCF client proxy. The only way I was even able to see that error was via SQL Profiler and by executing the code it captured but that’s because we do not have good logging setup on our WCF endpoints yet. After much pain and debugging I found that it was because I forgot to add (or accidentally removed) a critical piece when setting this up, so yes it all comes down to user ID10T error but isn’t it always.

m_cmd.CommandType = CommandType.StoredProcedure

Hope this helps someone, off to refill my coffee cup!


Written by lordfu

August 30, 2012 at 9:52 am

Visual Studio – Method Auto Comment (XML Documentation) Not Working

with one comment

Opened up a project that was started by a fellow developer at work, I got_set_to_write_code and wanted to do what all good developers do, they comment their code! 🙂
I needed to add a method comment which can be triggered by typing three ticks ”’. It stubs out

But it didn’t work, grrr. The fix:
1. Go into project properties
2. Select the Compile tab.
3. Check ‘Generate XML documentation file’

Now the auto comment shortcut should work.

Written by lordfu

July 31, 2012 at 10:33 am

Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled. Ajax Toolkit – Update Panel and Datagrid download button

with 8 comments

So I have a datagrid which is a listing of files in a network share. I have a linkbutton in the grid with its text property set to a filename. This datagrid sits inside an UpdatePanel so it is all ‘Ajaxified’. When testing the command on the link button I received the following error.
Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.

Now I do understand why I received this error, I had modified the output stream back to the client via AddHeader methods etc but I need to in order to get this file back to client!

Well fortunately there is a way to tell the Ajax parser code on the client that content coming back was modified on the server side via script manager and also by registering the datagrid as a postback control.

ScriptManager _scriptManager = ScriptManager.GetCurrent(this.Page); _scriptManager.RegisterPostBackControl(myDataGridID);

Hope this helps!!

Written by lordfu

September 24, 2010 at 2:11 pm

Posted in Ajax, ASP.Net, C#, Development

Internet Explorer cannot display the webpage because of fileupload size

with one comment

So I was adding an input for the file upload control. Upon upload I would check the file size against a known size limit within my application. While testing trying to exceed the maximum upload size limit I was receiving from Internet Explorer a “..cannot display the web page error.” So I tried doing a try catch within the page to see if I could catch an error but the error couldn’t be caught there. Once I figured out that the error was never going to be caught there due to the nature of the request/response cycle I thought about trying to catch the error within Global.asax but that seemed hokey considering all I wanted to do was to display a message to the user that they had exceeded the limit. Well the answer lay in the web.config. What I needed to do was tell the web server (I was using Visual Studio built in) that it’s OK to allow file uploads of ‘X’ size. Where X is larger than the maximum size you want your application to allow for file uploads, in my case 5MB. So I added the following into the
system.web element of the web.config.
httpRuntime executionTimeout="600" maxRequestLength="6000"

I then throw an InvalidOperationException when checking for file upload size and catch that within my interface and display a nice friendly “sorry too large” message.

Hope that helps!

Written by lordfu

September 24, 2010 at 10:31 am

Posted in ASP.Net, Development

Single line if statement C#

leave a comment »

Who doesn’t like doing more in one line of code!

Here is a standard if else statement in C# .

if (Age == 36)
isMyAge = true;
isMyAge = false;

Here is the same as a single line.

isMyAge = (Age == 36) ? true : false;

Now obviously this is not a great example because the same code above could be shortened to

isMyAge = (Age == 36);

But you get the point 🙂

Written by lordfu

September 17, 2010 at 2:49 pm

Posted in ASP.Net, C#

Install Ajax Control Toolkit – Visual Studio 2008

with 4 comments

When you create a new ASP.NET application or web-site in VS 2008 that targets the .NET 3.5 framework, VS will automatically add the appropriate AJAX registrations in your web.config file and the core ASP.NET AJAX server controls will show up in your toolbox. This post shows you how to register the rest of the extensions in VS 2008.

Download the Ajax Control Toolkit

Click the Downloads tab at the CodePlex site to see the list of available Ajax Control Toolkit downloads. If you are using Visual Studio 2010 then you can use either the .NET 4 or .NET 3.5 versions of the Ajax Control Toolkit.

Download the Binary version and not the Source version of the Ajax Control Toolkit. You should download the Source version of the Ajax Control Toolkit only when you are interested in extending the Ajax Control Toolkit.

Extract the Download
After downloading the Ajax Control Toolkit, you need to unblock and extract the files. Right-click the compressed file and click the Unblock button.

Next, right-click the compressed file and select the Extract All menu option.

Add the Ajax Control Toolkit to the Visual Studio Toolbox
The next step is to add the Ajax Control Toolkit to the Visual Studio Toolbox. Follow these steps:

1. Launch Visual Studio and create a new ASP.NET Web Forms project or website. Open Default.aspx in the Visual Studio editor.
2. Create a new Toolbox tab by right-clicking the Toolbox and selecting Add Tab. Name the new tab Ajax Control Toolkit.
3. Right-click beneath the new tab and select the menu option Choose Items… Click the Browse button and browse to the folder where you extracted the Ajax Control Toolkit. Pick the AjaxControlToolkit.dll and click the OK button to close the Choose Toolbox Items dialog.

Hope that helps!

Written by lordfu

July 14, 2010 at 4:13 pm

Posted in Ajax, ASP.Net, Development

Breakpoint is hit only for split second

leave a comment »

Frustrating to say the least. Googling makes it even worse because of the vast amount of users that actually receive a message from Visual Studio but that have nothing to do with my problem.

Here was my scenario. I put a break point on the first line of some code within Page_Load, obviously this would get called and is not bound by any condition but it was never hit!

The solution was to make sure all instances of Internet Explorer were closed and then my breakpoint was hit. This affected me in both Visual Studio 2003 and Visual Studio 2005.

Hope that helps.

Written by lordfu

July 12, 2010 at 1:22 pm

Posted in ASP.Net, Development