Archive for July, 2008
Saturday, July 19th, 2008
RegisterClientScriptBlock Example
Whiel using the AJAXToolkit i came up with the situation where i needed to run some javascript after a server-side event was called. After poking around for a bit i found the command “ScriptManager.RegisterClientScriptBlock”. This command sends back asynchronously javascript that will be executed by the clients browser on update. Here is an example:-
string strscript [...]
|No Comments » - Posted in AJAX, CSharp Commands, javascript | by admin
Saturday, July 19th, 2008
Redimension An Array CSharp
Here is a function to redimension an array in csharp:-
private static void ReDim(ref TextBox[] arr, int length)
{
try
{
if (arr == null)
[...]
No Comments » - Posted in CSharp Commands | by admin
Saturday, July 19th, 2008
isNumeric String Checker
Here is a way to check if a string is a number:-
public static bool isNumeric(string val, System.Globalization.NumberStyles NumberStyle)
{
Double result;
return Double.TryParse(val, NumberStyle, System.Globalization.CultureInfo.CurrentCulture, out result);
}
Here is a link so you can figure [...]
|No Comments » - Posted in CSharp Commands | by admin
Saturday, July 19th, 2008
Changing the MasterPageFile Dynamically
In a project i had been working on i wanted to have a central MasterPageFile that had variable sub MasterPageFile’s. I finally figured out that you have to override the “OnPreInit” Event on the page you wish to modify. Here is an example:-
protected override void OnPreInit(EventArgs e)
{
[...]
No Comments » - Posted in CSharp Commands | by admin
Saturday, July 19th, 2008
Image Resize With CSharp
Often it is necessary to resize an image that has been uploaded. To do this you will need the following using classes:-
using System.Drawing;
using System.Drawing.Imaging;
Then here are some examples on functions with the resize code:-
public static string ResizeImageAndSave(int Width, int Height, string imageUrl,string destPath)
{
System.Drawing.Image fullSizeImg = System.Drawing.Image.FromFile(HttpContext.Current.Server.MapPath(imageUrl));
[...]
No Comments » - Posted in Graphics | by admin
Saturday, July 19th, 2008
File.Delete Command
Here is an example on how to delete files in the file sytem:-
public static void DeleteFile(string FilePath)
{
try
{
FileInfo TheFile = new FileInfo(HttpContext.Current.Server.MapPath(FilePath));
[...]
No Comments » - Posted in CSharp Commands | by admin
Saturday, July 19th, 2008
Guest Speaker
when my erstwhile friend daniel first suggested that i should expatiate my views on the problems related with the evolving power of the computer and the concomitant ever increasing perception of the validity of it per se i thought that as a subject it w3aqs axiomatic as to answers that most reasonable people of a [...]
|No Comments » - Posted in Uncategorized | by admin
Saturday, July 19th, 2008
Accessing Post Variables in C# ASP.Net
I was writing dynamic form variables to the page and i needed to retrieve their values when updated. When i tried to access the variables with request.params[] collection i noticed that the keys were what id i had given them with a string appended to the start. I wrote this function to easiliy access the [...]
|No Comments » - Posted in Uncategorized | by admin
Thursday, July 17th, 2008
Colour Picker
I needed to have custom colours in my project so i looked at a few controls out there and the one i chose is from http://www.obout.com/ It seemed to do the job quite nicely.
|No Comments » - Posted in User Interface | by admin
Wednesday, July 16th, 2008
Writing Dynamically To The Page
I was making a yearly calendar and i needed to output the cells to represent the days in the year. At first i just made a public variable, filled it up with html and then outputed it to the page like this:-
1
<%=variablename%>
This seemed to work well but the page didn’t update on postback methods because [...]
|