Skip to main content

Posts

Silverlight 2.0

I was at a monthly .NET usergroup meeting yesterday. Larry Clarkin ( http://larryclarkin.com/ ) was there, and he was kind enough to give out quite a few copies of Visual Studio 2008. I was one of the ones who needed a copy. Never had the justification to buy it personally. Actually I am using 2005 at work too, but anyways… He talked about Silverlight 2. It has quite a few unique features that make it interesting enough to start “playing” around with. The most interesting aspect to me is the subset of the .NET framework embedded into the Silverlight runtime, which in turn means you can write Silverlight programs in C#/VB.NET (as well as a few other languages). Another plus is that it has built-in form controls. Put those two together and it could be interesting to make some rich web applications with not much difficulty. All this time I though it was just a Flash clone. Check out silverlight.net for more of the specifics.

Learning About .NET Web Access Classes

I mentioned about wanting to start a business in my previous post. Well it looks like I might have my chance. While it isn’t exactly what I was thinking of in my previous post, I foresee many opportunities to flex my programming muscle in this endeavor. Plus, I will be starting up with a good friend, so there is a good chance our motivation will actually produce some results. A piece of software I am starting to research/design/create will be an internal application we will use to automatically extract some government provided public data. The current issue is time. With the amount of data and the requirement of using their web interface, it is not worth the time needed to do it by hand. The only other option would be to buy the data from the government, but that’s just an unnecessary cost seeing as there is a free option available. So I will be writing a program in C# to automatically access a few websites and download the needed data in chunks. I have never delt with .NET’s we...

JavaScript Tip: Submit Form On Enter Key

A common practice with search forms is to have them submit when the enter key is pressed, instead of requiring the user to use their mouse to press the submit button (or using tab key to tab to the submit button). Update: I attempted to find a solution for working in Firefox, but the code I added has not been tested personally. Here is a simple way to do that in JavaScript: First, define a input box: <input name="txtsearchentries" id="txtsearchentries" type="text" size="13" value="" /> Second, create a function to be placed in the head area of the webpage: // see if the user pressed the enter key  // while using a specific control  function submitSearchOnEnter(variable) {     if (window.event) {         // keyCode = window.event.keyCode;         // this doesn't seem to work in Firefox,          // so try the code below...          keyCode = event.keyCode ? event.keyCode :...

Objects in Javascript

Javascript does not use a standard class model. It uses objects that are like associative array structures of data, or so I have read. Regardless of how it works, you can make a class-ish type construct in Javascript. I’ll try to go over the basics here to help anyone who is interested. Objects are defined by creating a new function. Inside the function you can define variables and methods that are attached to the primary function. The primary function is really like the constructor for the object as well. For example: function ObjectExample(constructorParameter1, constructorParameter2) {  //define a variable and assign a constructor value to it  this.variable1 = constructorParameter1;  //you can also define variables with var, but they act differently  this.variable2 = constructorParameter2;            //assigns an instance pointer to a "constructor" variable  var variable3 = this;  //defines a funct...

Javascript Rant

I’ve been working on something recently where I decided to have most of the program run in a client’s browser. It’s basically a blog system that works with that asp-xml-to-access-db class. The clients browser sends/requests information in XML to the server script and everything turned out peachy. I’m overall extremely happy with it. Now that I’m done writing the script. I learned quite a bit more about Javascript that I didn’t know in the past. The initial few days of working with it were tragic. I’m not too fond of Javascript’s (pseudo) object model and lack of a standard class model. While Javascript works and provides a good deal of functionality, it feels dirty. Maybe my fellow “old school” programmers can understand. Besides the object model, the DOM in general is a pain to work with, and hard to find information about (that works in multiple browsers). Inconsistencies, things that logically should work don’t,...

DLL Files And .NET ClickOnce Deployment

I want to deploy one of my .NET apps as a ClickOnce application. The issue is that I am connecting to Oracle (see previous posts here and here ). Connecting to Oracle requires at least, 4 DLL files that generally have to be in the same directory as the EXE file. The issue is that when the program is published, the DLLs are not referenced in any way, so the program won’t work. Then I read about adding the files to the project, so that ClickOnce and the Publish processor will figure out that the DLLs are required and add them to the manifest. Here is the process in Visual Studio 2005: Put the 4 DLL files in their own directory in your solution directory (for ease of use mostly). Add all four files to your project by going to “Project->Add Existing Item…” Click on each DLL file in the solution explorer and then change their property: “Copy To Output Directory” to “Copy Always”. That’s it! Now when I publish or even run the application I don’t have to worry about if the DLL files...

C# .NET Programming Tip: Oracle Connection Revised

Take not that Microsoft will discontinue support for System.Data.OracleClient in .NET 4.0. This method should still work, but it will be depreciated… Now that I have had more time to work with Oracle, I found a better way to connect then described in my previous post . With this new method you can connect to multiple instances in one program by getting rid of that tnsnames file. *Remember that a project reference to System.Data.OracleClient must be added: OracleConnection dbConnection; string connectionString = "Server=(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = *******)(PORT = 1521))(CONNECT_DATA = (SID = *****)));Persist Security Info=true;User Id=*****;Password=*****;"; dbConnection = new OracleConnection(connectionString); It’s really that simple. The key here is that the connection string must use the “Server” attribute instead of the “Data Source” one. I ran upon that while looking at the specification on Microsoft’s MSDN documentation site. It’s basically a t...

C# .NET Programming Tip: Types

Figuring out a variable’s type has become more important since now variables can be boxed by their parent class(s) (Where all can be “Object”). It’s nice because it allows for one generalized function to work with many types that perform an action on a common attribute, or first figure out what the object is and then perform the action. That is one of the instances where figuring out a variables type is important. .NET has a built-in function called GetType() which figures out what type a variable is. //loop through the controls in the panel and figure out  //which of the checkboxes are checked  foreach (Control panelControl in newCheckListQuestionPanel.Controls) {       //only continue if this control is a checkbox      if(panelControl.GetType().ToString()      .Equals("System.Windows.Forms.CheckBox") == true)      {           if (((CheckBox)panelControl).Checked == true)  ...

C# .NET Programming Tip: Connecting to an Oracle Database

Take not that Microsoft will discontinue support for System.Data.OracleClient in .NET 4.0. This method should still work, but it will be depreciated… Please view this post for a better way to connect to Oracle. Ugh, I spent a good 6 hours figuring out how to do this! Hopefully this post can save someone some time. Connecting to an Oracle database requires driver files from Oracle. This is true no matter what you use in Visual Studio, it true for System.Data.ODBC or whatever else. This little factoid took me a while to figure out, as I didn’t want to believe that I had to install a 200mb piece of software from Oracle just to connect to one of their databases. Well thankfully I didn’t have to install their standard client. They offer an “instant client” that is quite a bit smaller. They even offer a lite version of the instant client, which is the one I decided to use. The bad thing about it is even that is around 20mb in size. You can download it here: http://www.oracle.com/tec...

C# .NET Programming Tip: Keeping A History With Properties

The program I am writing at work’s primary functionality is a checklist. One of the requested features is the ability to record what actions a user performs on the checklist. So there needs to be some additional code that updates a history table whenever a user makes any changes to the checklist. Let’s define when a history event should fire off: When the user makes a new checklist. When the user updates any property of the checklist. When a user archives a checklist (eg: discard in so many words). Making a history entry when the user makes a new checklist or archives a checklist is easy. There would generally be only one function for each, so just before or after adding or archiving the checklist from the database, the history process is called. What about when the user updates a single field in a checklist? It is important to track those changes, because a single little change is generally the most important (he said, she said situation). In my program checklistprocessor, checkli...