Showing posts with label Windows. Show all posts
Showing posts with label Windows. Show all posts

Saturday, January 24, 2015

Comparing Web Forms And ASP.NET MVC


I first saw Microsoft ASP.NET in action in 2004, when it was tentatively named ASP+. At that time, building a Web application on the Microsoft platform was a matter of assembling a bunch of Active Server Pages (ASP). In a typical ASP page, you find HTML literals interspersed with code blocks. In code blocks, script code (mostly VBScript) is used to incorporate data generated by COM objects, such as components from the ActiveX Data Objects (ADO) framework. Undoubtedly, the introduction of ASP.NET in the late 1990s was a big step forward, as it represented a smart way to automate the production of HTML displayed in a client's browser. ASP.NET simplified a number of everyday tasks and, more importantly, enabled developers to work at a higher level of abstraction.This allowed them to focus more on the core functions of the Web application rather than on common tasks around Web page design. Based on server controls, ASP.NET allows developers to build real-world Web sites and applications with minimal HTML and JavaScript skills. The whole point of ASP.NET is productivity, achieved through powerful tools integrated in the runtime as well as the provision of development facilities, such as server controls, user controls, postback events, viewstate, forms authentication, and intrinsic objects. The model behind ASP.NET is called Web Forms and it was clearly inspired by the desktop Windows Forms model (in turn deeply inspired by the Visual Basic Rapid Application Development philosophy). So why did Microsoft release "another" ASP.NET framework, called ASP.NET MVC?


Benefits of ASP.NET Web Forms
As noted, ASP.NET Web Forms is stable and mature, and it is supported by heaps of third party controls and tools. One of the keys to the rapid adoption of ASP.NET is certainly the point-and-click metaphor taken from Windows desktop development. With Web Forms, Microsoft basically extended the Visual Basic programming model to the Web. Desktop development, however, is stateful whereas the Web is inherently stateless. So the Web Forms model essentially abstracted a number of features to provide a simulated stateful model for Web developers. As a result, you didn't have to be a Web expert with a lot of HTML and JavaScript knowledge to write effective Web applications. To simulate stateful programming over the Web, ASP.NET Web Forms introduced features such as viewstate, postbacks, and an overall event-driven paradigm.For example, the developer can, say, double-click on a button to automatically generate a stub of code that will handle the user's clicking to the server. To get started writing an ASP.NET Web application, you just need to know the basics of .NET development, the programming interface of some components, like server controls. Server controls that generate HTML programmatically, and the runtime pipeline, contribute significantly to a fast development cycle. At the end of the day, key features of ASP.NET Web Forms are just the componentization of some ASP best practices. For example, postback, auto-population of input fields, authentication and authorization before page rendering, server controls, and compilation of the page, are not features devised and created from scratch for ASP.NET Web Forms. All of them evolved from ASP best practices. Ten years ago, ASP developers (including myself) were looking for exactly the set of features that ASP.NET Web Forms ended up providing. Furthermore, ASP.NET Web Forms generally exceeded our expectations by providing a full abstraction layer atop the whole Web stack: JavaScript, CSS, HTML. To write an ASP page, you did need to know quite a bit about the Web and script languages. To write an ASP.NET page, in contrast, you need to know primarily about .NET and its compiled languages. Productivity and rapid development of data-driven, line-of-business applications have been the selling points of ASP.NET Web Forms. Until now, that is.


Drawbacks of ASP.NET MVC
ASP.NET MVC brings to the table a clean design with a neat separation of concerns, a leaner run-time stack, full control over HTML, an unparalleled level of extensibility, and a working environment that enables, not penalizes, test-driven development (TDD). Is ASP.NET MVC, therefore, a paradise for Web developers? Just like with Web Forms, what some perceive as a clear strength of ASP.NET MVC, others may see as a weakness. For example, full control over HTML, JavaScript, and CSS, ASP.NET MVC means that you enter the Web elements manually. Much of this pain can be mitigated, however, with some of the more recent JavaScript libraries and even different view engine. In general, though, there's no sort of component model to help you with the generation of HTML, as there is in the Web Forms approach. Currently, HTML helpers and user controls are the only tools you can leverage to write HTML more quickly. As a result, , some ASP.NET developers may see ASP.NET MVC as taking a step backward in terms of usability and productivity. Another point to be made, regarding the impact of ASP.NET MVC on everyday development, is that it requires some upfront familiarity with the MVC pattern. You need to know how controllers and views work together in the ASP.NET implementation. In other words, ASP.NET MVC is not something you can easily learn by experimenting. In my experience, this may be the source of decreased productivity for the average Web Forms developer.

Tuesday, January 20, 2015

Basic Tips for Software Development Managers

Basic Tips for Software Development Managers

1. Look out for pitfalls in project requirements
2. Build the right team
3. Facilitate communication between developers

All software projects are different and each new task might bring unexpected challenges for the team in the middle of a development phase. However, by following some basic concepts mentioned above, project managers can minimize potential risks before even starting development. Having built a good foundation, you can make sure you have enough time and resources to finish every project well and on time.

Monday, April 21, 2014

C# How to: Add and Clear Items in a ListBox Control


This example adds the contents of a Windows Forms TextBox control to a ListBox control when you click button1, and clears the contents when you click button2.

Example 1:

private void button1_Click(object sender, System.EventArgs e)
{
    listBox1.Items.Add("Sally");
    listBox1.Items.Add("Craig");
}

private void button2_Click(object sender, System.EventArgs e)
{
    listBox1.Items.Clear();
}

Wednesday, January 01, 2014

Validation Using Regular Expressions on c# windows form

Regular expressions are great way to validate data provided by a user to the fields of a form. Suppose that a user should input an age rather than a name, or an address rather than a gender, you can use power of regular expressions to validate them. The following example creates a simple windows forms application that demonstrates the use of regular expression in validating each fields of a form. Create a new windows forms application and add the below Textbox as per given label names.

LabelTypeNameProperty Values
1TextBoxfirstNameTextBox
2TextBoxlastNameTextBox
3TextBoxageTextBox
4TextBoxgenderTextBox
5TextBoxaddressTextBox
6TextBoxzipCodeTextBox
7ButtonsubmitButtonTextSubmit

 Although we can use radio buttons for the Gender field, we will be using a text box to demonstrate validation of text using regular expressions. Double click the submitButton to generate an event handler for its Click event. Be sure to import System.Text for the StringBuilder class that we will use andSystem.Text.RegularExpressions for the Regex class.

using System.Text;
using System.Text.RegularExpressions;

We should also declare a StringBuilder and Regex members in our Program class.
private StringBuilder errors;
private Regex validator;
 Use the following code for the Click event handler of submitButton.
private void submitButton_Click(object sender, EventArgs e)
{
    if (AreFieldsValid())
    {
        //Do task here
    }
}
The following is the code for AreFieldsValid() method.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
private bool AreFieldsValid()
{
    errors = new StringBuilder();
 
    //Validate First Name and Last Name
    validator = new Regex(@"^([A-Z][a-z]+)(\s[A-Z][a-z]+)*$");
 
    if (!validator.Match(firstNameTextBox.Text).Success)
        errors.AppendLine("First name is not in the proper format.");
 
    if (!validator.Match(lastNameTextBox.Text).Success)
        errors.AppendLine("Last name is not in the proper format.");
 
    //Validate Age
    validator = new Regex(@"^\d{1,2}$");
 
    if (!validator.IsMatch(ageTextBox.Text))
        errors.AppendLine("Invalid Age.");
 
    //Validate Gender
    validator = new Regex(@"^([M|m]ale|[F|f]emale)$");
 
    if (!validator.IsMatch(genderTextBox.Text))
        errors.AppendLine("Invalid Gender.");
 
    //Validate Address
    validator = new Regex(@"^[0-9]+(\s[a-zA-Z]+)+$");
 
    if (!validator.IsMatch(addressTextBox.Text))
        errors.AppendLine("Address is not in the proper format.");
 
    //Validate ZipCode
    validator = new Regex(@"^\d{4}$");
 
    if (!validator.IsMatch(zipCodeTextBox.Text))
        errors.AppendLine("Invalid zip code");
 
    if (errors.ToString() == String.Empty)
    {
        return true;
    }
    else
    {
        MessageBox.Show(errors.ToString(), "Validation Failed", 
            MessageBoxButtons.OK, MessageBoxIcon.Error);
 
        return false;
    }
}

Monday, December 16, 2013

Adding BlueTooth the device

Adding BlueTooth the device

When the AirCable device has been properly configured it will be available (discoverable) as a Bluetooth device. Click Add on the Bluetooth Devices dialog as shown below.
BlueTooth Devices

Click Add to see a list of Bluetooth devices
Because the device has already been configured to be "Discoverable" and the serial port option enabled you can use the "Add" Bluetooth Device Wizard to find the device by name.

Check My device is set up and ready to be found
Press NEXT

Find the AirCable device by name
(assuming you assigned AirCable to the device)

Choose Next

No Name assigned to the device

If you have not given the device a name it will show only as "New" device, not AirCable as shown above. Best to go back and use a name so you can be sure what you are connecting to.

No name given

Better to assign a name like AirCable for clarity!

Because Authentication is being used you will have to enter the PIN number assigned to the device. Again, in my experience using Authentication has always worked and poses not problems!

Enter PIN number here <---click font="" for="" here="" location="" pin="">

Press next

WARNING!

YOU MUST SEE THE FOLLOWING TAKE PLACE after double mouse clicking on the device name and entering the PIN!

Brief message you must see!
Note the pass key being used

Note Windows COM PORT assignments here!

Two Com port assignments is normal!

You must see two COM PORT assignments as shown above. One incoming and one outgoing. You use the Outgoing COM Port in TheSky! See above using COM PORT #94. If you do not see the two com ports go back and double check the device settings. Without an incoming and outgoing port the connection in TheSky will fail to connect to the device.

Show Bluetooth Devices - A double check!


Task Bar

Right-click on the Bluetooth icon to access the Bluetooth menu.

Show Bluetooth devices

Double check the COM port settings

DO NOT CONTINUE UNTIL YOU HAVE THE TWO PORTS Incoming and Outgoing SHOWN HERE on the Bluetooth Devices | COM Ports tab. The ONLY exception is using the Air Cable USB to Serial adapter and Bluetooth serial port. This is also true when using Windows Mobile device.

Properties Tab on Bluetooth devices
  
Display the Com Ports assigned
Use Com Ports tab

The COM port assignment here the Outgoing on COM41 is then set in TheSky's Telescope Setup.

Another check

After the device has been discovered and the COM PORT assigned to the system you can see the COM PORT number you need to enter in TheSky using the Properties of the device. Choose the Devices Tab then Properties.

Device Tab

Click Properties

Serial Port Service Shown!

Here is the COM port to use in TheSky!

You can now connect to the telescope wirelessly using OUTGOING port COM71 above. Telescope | Link Establish using the settings Paramount ME using Com71. See the section Entering the COM PORT in TheSkyfor details.

Improper configuration - No Serial Port Service found or only one com port

This will NOT work!

You must have an incoming and outgoing port!

If you attempt to "Add" the Outgoing port by forcing it you will see the following error message! This indicates that the device settings have not been configured properly. You cannot continue until both the ingoing and outgoing ports are shown.

web reff: 
http://www.bisque.com/tom/bluetooth/aircable.asp#Windows Device Manager

Wednesday, May 08, 2013

How to Convert Numbers To Arabic Word and English Words ( .NET / C# )

The new version you can see from the link.
Convert numbers to Arabic words 
 In this article, I will talk about converting numbers to words in English and Arabic words. 
I have many request for Convert Numbers To Arabic Word so I have decided to go the long way to build a class to do the conversion to Arabic and also added English language support.
This versions of numbers: one for Number to English text number and one for Arabic number text.
Here is a screen shot of a test project that uses the class:



This article contains code that does a good convert for a decimal value into its equivalent English words, but numbers from my application were actually money amounts, so I needed to add currency names to it (our project is also multinational, so I had to build the string dynamically from the country’s currency).

This was the easy part after I made a few small changes to Justin’s code to fulfill my English-Number-To-Words requirements.
You can DOWNLOAD the full Project from the link below.

.NET Code download


Download EXE file to RUN