V J

Saturday, February 12, 2005

RE (Regular Expressions) Which Need To Memorize (Remeber, rem IT)

Dear All, Something very tiny, but everyone needs it time by time, so dont forget to have it all in your toolBox. And this is RE's (Regular Expression), especially when you are validating input, like validating numerics, alpha, alphanumeric, email address, etc. Some of the most common are as below. For Numeric, use : ^[1234567890]* For Alpha Numeric, use : ^[_A-Za-z0-9 ]* For Alpha, use : ^[_A-Za-z ]* For Email, use : \w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)* Just parse input data with these RE's and get your code ready to have a showcase :) Remember in prayers, Wajahat Abbas

Monday, February 07, 2005

Quote for the Day

One of the really coolest quote i do like most! "Champions aren't made in gyms. Champions are made from something they have deep inside them - a desire, a dream, a vision. They have to have last-minute stamina, they have to be a little faster, they have to have the skill and the will. But the will must be stronger than the skill." -- Muhammad Ali

Accessing Embedded Recources From Assebmly

Dear All.. We will see here, how to access embedded recourses of an Assembly. Like, if you have designed some html pages, and you want to show, consume in your page (asp.net), or any template, any text file, you just want to consume that file into your page. A typical scenario is the one, in which your program needs to email html messages, which can modified and changed,,, you want to consume those html pages in your email. Create a Vb.Net windows project, named it ReadingAssemblies, add a html page and name it MyPage.htm, in this html page, write anything,, like "hello World "(Most formal start :)) After that click on the file and in the properties window, modify the Build Action with Embedded Recourse because this will allow your page to embed as a recourse which can be accessed consuming the assembly .Now this file will be a part of your ReadingAssemblies, Add a form , add a button and a richtextbox in your form. Add the following code in your Button Click event, '********************************************************************* Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim execAssembly As [Assembly] ' Taking instance of Assembly execAssembly = [Assembly].GetExecutingAssembly ' Getting the Executing Assembly (own) Dim iStream As Stream ' Getting whole stream of Html page in a stram object iStream = execAssembly.GetManifestResourceStream("ReadingAssemblies.MyPage.htm") Dim bStream As New StreamReader(iStream) ' Reading the stream object rchTextBox.Text = bStream.ReadToEnd ' Showing the whole file in a richtextbox End Sub '********************************************************************* So you have seen that how simple to access any file. We just created a html page, change it build action, and then consume it... Its one of the simplest way to consume embedded resource. .Nitting, Wajahat Abbas

Saturday, February 05, 2005

Thought for the Day

"Water is fluid, soft, and yielding.But water will wear away rock, which is rigid and cannot yield.As a rule,whatever is fluid, soft, and yielding will overcome whatever is rigid and hard. This is another paradox: what is soft is strong." Lao-Tzu. Try this principle next time you're in an argument with someone.Being fluid, soft and yielding means being flexible, and the more flexible you are, the better your chances of coming up with something constructive. If you lock into a certain position, you put yourself in an extremely limited position. Don't be the rock, be the water!

Tuesday, February 01, 2005

A must to read Quote

" It's about turtles. That says that Turtle can be safe if they stay inside the shell, but progress comes when they stick their head out. "
David Ogilvy (O&M)

JavaScript Pop up Alert on DataGrid

Well Guys, A very nitty gritty code but i am sure that everyone needs it, especially when you have a Datagrid with some functionality (edit, delete, etc). As methods like delete must be verified , must be remind before the action performed, we need the confirmation of the user, rather deleting the record at the first instance. You must give him atleast a single LifeLine :). The scenrio is, you want to show a javascript alert before you delete a record. What you have to do is very simple. You just need to dig into your Datagrid (Itembound event), and add following code. ********************************************************** Private Sub DealerViewGrid_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DealerViewGrid.ItemDataBound If e.Item.ItemType = ListItemType.AlternatingItem Or _ e.Item.ItemType = ListItemType.Item Then Dim deletebutton As Button deletebutton = e.Item.Cells(8).Controls(0) deletebutton.Attributes.Add("onclick", "javascript:if(confirm('Are you sure to delete?')== false) return false;") End If End Sub ********************************************************** Like in my case, i have a datagrid delete command button (delete). In the itembound event i take a deletebutton instance as a button, and then i add an attribute with this button, a javascript confirm message, which will open a dialouge box and ask "Are you sure to delete", if clicks "Yes". It will perform the desire as written inside the DataGrid_DeleteCommand, and if cancel clicked. It will left as it was. No ACTION. So this is how you can add an javascript attribute in a DataGrid button. If you love those who love you, what’s great, its everyone do. Move Ahead Love those who Persecuted You. You deserve to be GREAT. [Extracted from (Passion of the Christ)]