Articles for Csharp and ASP dot net
-
Call multiple ajax calls in sequence, rather than all at the same time
0 comments Read More -
Visual Studio Profiler setup
0 commentsThis will show the slowest functions in your code.
Read More -
How to set up SignalR in MVC3, asp.net 4.6, in VS2013
0 comments Read More -
Web scraping with html agility pack
0 comments Read More -
Make Select2 Dropbox to work like an autocomplete
0 commentsLoad data based on what you type instead of loading all of it together
Read More -
How to create a unique reference number
0 comments Read More -
Ascii art - excel to source code table
0 commentsIf you want to paste an example from excel into your source code - use this
Read More -
ASP.NET Error Messages
70 commentsThe following error messages are those typically encountered due to site configuration and other general conditions that are not obvious compilation or runtime errors. As our standard platform is ASP.NET MVC 2, many of the solutions assume that is the platform. If you get an IIS error that you ca...
Read More -
simple sync code
0 commentsIf you need to sync something from an API or service based data source, with a local db - here is an example.
Read More -
ABC PDF Versions Mismatch - update!
0 comments Read More -
Error: Collection was modified; enumeration operation may not execute
0 comments Read More -
Ignore service end point security errors
0 commentsWhen in server to server discussion, is it ok to ignore the cert errors?
Read More -
Lawson M3 / Infor web service calls
3 commentsLawson M3 / Infor web service calls
Read More -
Image drawing example
1 commentsHow to draw a custom image using c# code
Read More -
How to write an mvc view to a string
4 commentsuseful when returning ajax
Read More -
HTML fragments in view page - can be called over and over - eg in a loop
1 commentsWhen you are writing a report, sometimes you have a chunk of html that you need to call over and over - like subtotal. You can use an Action and an anoymous 'function' full of html to do this. - like a renderaction and an ascx, but inline on the page. This reduces files in the project, and you dont need an actionresult method in the controller.
Read More -
How to use jsonp and mvc to cross domains when we control both domains
1 commentsSometimes you need to call ajax on a different server. Thies is how to use jsonp and mvc to cross domains when we control both domains
Read More -
C# How to sort a list that is already in memory
1 commentsHere is how, with an example of sorting a structured memory object using icomparer
Read More -
World Clock
0 commentsTime Calculator
Read More -
Access to the registry key 'Global' is denied
7 commentsA workaround to this issue
Read More -
Colourbox and forms
9 commentsProblems when forms disappear from colorbox (colorpowered)
Read More -
C# timer, how to add duration to a page
56 commentspage / function timer code
Read More -
Sample email template code
0 commentsHow to send email from c# using a textblock template
Read More -
Routing issues in MVC
7 commentsI had an issue when including a warningbar in admin, caused by strange routing behaviour in MVC related to html.renderaction and html.action
Read More -
Cookie as a property get/set
0 commentsRead More
-
Code snippet for creating a PDF from an HTML page using abcpdf
11 commentsThis function calls an html page, creates a pdf from it, saves it to a month stamped folder /// /// note: to add page break, add around the place /// /// file name of pdf created public string BuildPdf_ABCPDF() { //create document //String htmlText = ""; var newFileName ...
Read More -
HTTPget sync and async version
5 commentsSometimes you need to read a remote ( or local ) web page for scraping the content or ajax save, etc. Async version has been tested by calling it 10000 times, and watching the threads for leaks - no problems found. This is good when you want to do a lengthy process in the background, when the use...
Read More -
abcPDF installation errors
0 commentsIE9 Issues abcPDF uses the MSHtml rendering engine that is built in to windows on the server. If IE is upgraded to IE9 this can cause an issue where a previously relied on GDI call is no longer available. IE8 will be upgraded automatically to IE9 via windows update unless you are careful with windo...
Read More -
How to set up a development environment
0 commentsIn order to make a stand alone dev system (on a laptop for example), you need to go to the following place: http://www.microsoft.com/express Get a copy of : - visual studio express 2010, c#.net addition http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-web-developer-exp...
Read More -
Security
1 commentsAntiXSS and Anti SQL Injection engine and encoders - looks interesting if we find our existing solutions inadequate http://wpl.codeplex.com/
Read More -
How to sort a sql query in memory
0 comments<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test35.aspx.cs" Inherits="Test35" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="Beweb" %> <html> <head> <title></title> </head> <body> <% var sql = new Sql("selec...
Read More -
ABCpdf dot NET Manual Installation
0 commentsUPDATE: see http://www.websupergoo.com/helppdf7net/source/3-concepts/6-installation.htm since we are using version 7 on Edna for reference see http://www.websupergoo.com/helppdf5net/source/3-concepts/6-installation.htm To do this you will need the files: - ABCpdf.dll (C:\Program Files\WebSupergoo...
Read More -
How to do an 'include' or user control (ascx) in MVC, and pass data or model to it
0 commentsHow to do an 'include' in MVC, and pass data to it. in aspx <%Html.RenderAction<LifeInsuranceController>(controller=>controller.PopHealthRespiratory(record)); %> in controller. Note: record is the typed data you are passing to the ascx view public ActionResult PopHealthRespir...
Read More -
C Sharp Collection Classes
1 commentsHow to choose a Collection type in .NET .NET contains many different collection types and they all have slightly different behaviour and limitations. Extracted from MSDN http://msdn.microsoft.com/en-us/library/ms132438(v=VS.80).aspx Be sure to choose your collection class carefully. Using the wro...
Read More -
Use list to check for duplicates in a datarow
1 commentsIf you are walking through a dataset or datarow printing things out, you can skip duplicates by using a list to keep track of what you have done so far. var dupcheck = new List<string>(); foreach (DataRow dr in dt.Rows) { //rowIndex++; string partNumber = dr[1]+""; if(dupcheck.Contains(pa...
Read More -
Captcha
0 commentsI ran into a few problems with 'recaptcha' - i like it, but dont like how you need a site key for each one. Instead i decided to use MSCaptcha. Here is what I did: add this to web.config: <system.web> <httpHandlers> <add verb="GET" path="CaptchaImage.axd" type="MSCaptcha.Capt...
Read More -
Threading
1 commentsGood discussion of threading, including a FireAndForget utility, using the thread pool, delegates and Beginxxx()/Endxxx() method pairs. http://www.yoda.arachsys.com/csharp/threads/threadpool.shtml HTTP GET with WebClient This seems to be the simplest way of doing HTTP GETs and also provides a sim...
Read More -
Codelib Future
3 commentsLinks to possible things to implement in future Stongly typed web.config sections http://haacked.com/archive/2007/03/12/custom-configuration-sections-in-3-easy-steps.aspx An implementation of subforms: http://www.joncurtis.co.uk/ Capturing HTML response output to a string instead of sending d...
Read More -
Csharp Date functions
0 commentsprivate int GetAge(DateTime birthDate){ // cache the current time DateTime now = DateTime.Today; // today is fine, don't need the timestamp from now // get the difference in years int years = now.Year - birthDate.Year; // subtract another year if we're before the // birth day in the current year if...
Read More -
VBS and ASP to CS converter
0 commentsSick of ASP? Got some VBS you need to use? Here is a basic converter to get you started: VBS / ASP to CS converter It could do with a bit more work, so email me if you need the source, and you're a regex freak.
Read More -
Debugging
0 commentsSet debug with PDB-Only mode in the web.config: <system.codedom> <compilers> <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" compilerOptions="/debug:pdbo...
Read More -
Old style Custom Validators
4 commentsBasic Validators <asp:RequiredFieldValidator ControlToValidate="Password" ErrorMessage="password is required" ValidationGroup="sign_up" Display="None" runat="server" /> Email Validator <asp:RegularExpressionValidator ValidationGroup="sign_up" ControlToValidate="Email" ValidationExpres...
Read More -
Rounding
1 commentsThis may seem kind of obvious but in actual fact there are a couple of types of rounding, and there are lots of sites out there that explain it, but I'm going to keep it real simple here. Normal rounding: 3.4 -> 3 3.5 -> 4 3.6 -> 4 Round-to-even method (also known as unbiased rounding,...
Read More -
Inversion of control
0 commentsJames Kovacs' roll-your-own IoC container Very good introduction to dependency injection and inversion of control http://www.dnrtv.com/default.aspx?showNum=126
Read More -
Create, Insert, Update, Delete Raw (no ORM)
3 commentsvoid test1() { string sConnectionString = "Password=StrongPassword;User ID=UserName;" + "Initial Catalog=pubs;"+ "Data Source=(local)"; sConnectionString = Beweb.BewebData.GetConnectionString(); var objConn = new SqlConnection(sConnectionString); objConn.Open(); var daAuthors = new SqlD...
Read More -
Listview counter
0 commentsListview with a counter column: <asp:ListView ID="Top20Lv" DataSourceID="Top20Ds" runat="server"> <LayoutTemplate> <table cellspacing="0"> <tr> <th class="leftcol">#</th><th class="leftcol">People</th> </tr> <...
Read More