grab our rss feed

stevienova.com

Homepage of Steve Novoselac

Entries Tagged ‘ASP.NET’

Auto Submit Form in ASP.NET With Javascript

Not sure if this is the best way to do this, but this is what I do. Say you want to auto submit a form on an aspx page. You can call document.formname.submit(); from the body onLoad event and it will submit, but ASP.net will automatically post it back to itself.
I tried added buttons [...]

Leave a Comment | 140 views

ASP.NET C# - Grabbing a posted file and save to disk

Sometimes you want to grab a file posted to a page, maybe an image upload or other file upload
HttpFileCollection logFiles = Request.Files;
string path = System.Configuration.ConfigurationManager.AppSettings["LogPath"];
if (logFiles.Count > 0)
{
HttpPostedFile logFile = logFiles.Get(0);
logFile.SaveAs(path + System.Guid.NewGuid().ToString() + “.log”);
}
As you can see, I am setting the log path from the config. The reason for this is, the path to [...]

Comments (2) | 65 views

ScaleOut StateServer

ScaleOut Software has a product to manage sessions on a web farm. I have tried this product and have had nothing but issues. I did actually end up getting it working once, but it turns out, even when it does work correctly, it gives your network problems

It seems that the fix for any issue is [...]

Comments (3) | 124 views

VS2005 Unit Testing HttpContext Cache

been searching for a while on how to test HttpContext and Cache in VS2005 Unit Tests, using the built in unit testing suite. Found this today..just add
TextWriter tw = new StringWriter();
HttpWorkerRequest wr = new SimpleWorkerRequest(”/webapp”, “c:\\inetpub\\wwwroot\\webapp\\”, “default.aspx”, “”, tw);
HttpContext.Current = new HttpContext(wr);
to you test method and the correct “using” statements, and boom - it works [...]

Comments (4) | 169 views

VS2005 ASP.NET 2.0 “Ambiguous Match Found”

Sounds like some dating gameshow, where you are of the winner..and the date you get is someone you just aren’t sure of. Anyways, if you see this error in VS2005 (asp.net), what I have seen it means is: you have some control variables decalred in your codebehind file, and they are also declared in the [...]

Comments (10) | 860 views

‘Class’ must be marked as Serializable or have a TypeConverter other than ReferenceConverter to be put in viewstate.

What a PITA. If you want to store an object in the viewstate in ASP.net you need to make sure it is marked as Serializable. Not only that, you need to make sure that every class that it uses is marked as serializable.
There are some scenarios that you don’t have to thought: if you store [...]

Comments (2) | 184 views