Regular Expresstion for File Upload

Allowed file types : jpg, jpeg, png and gif

<asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" ControlToValidate="FileUpload1" Display="Dynamic" ErrorMessage="Photo is not valid" ValidationExpression="(.*?)\.(jpg|jpeg|png|gif|JPG|JPEG|PNG|GIF)$" ValidationGroup="add"> </asp:RegularExpressionValidator>

 

_______________*************************___________________

MaxLength For Multi Line TextBox

Max Length is only for normal textbox. its is not available for Multi Line TextBox. So I have written one java script to restrict the multi line test box max length.

 

Step 1: Script: Add this script in Head Tag...

 

<script type="text/javascript">

        function ismaxlength(obj, MaxLength) {

            var mlength = MaxLength

            if (obj.getAttribute && obj.value.length > mlength) {

                obj.value = obj.value.substring(0, mlength);

                alert('Text has been truncated to ' + MaxLength + ' characters.');

            }

        }

</script>

 

 

Step 2: Call this script on onkeyup and onblur events of the Multi Line textbox.

<asp:TextBox runat="server" ID="tbMessage" Rows="6" onkeyup="return ismaxlength(this,300)" onblur="return ismaxlength(this,300)" TextMode="MultiLine" Text=””></asp:TextBox>

 

That'z it.. it will work as u want in IE, FIREFOX and CHROME

 

_________________********************____________________

Tool Tip For DDL

 

<asp:DropDownList ID="ddlChapter" runat="server" OnDataBound="ddlChapter_DataBound"

                    onmouseover="showHideTooltip(this,event.type,event)">

 

 

 protected void ddlChapter_DataBound(object sender, EventArgs e)

    {

        DropDownList ddl = sender as DropDownList;

        if (ddl != null)

        {

            foreach (ListItem item in ddl.Items)

            {

                item.Attributes["title"] = item.Value;

   }

}

     }

 

 

  <script language="javascript" type="text/javascript">

 

        showHideTooltip = function(e, evtType, evt) {

 

            var obj = e;

 

            var ddl = document.getElementById('<%= ddlChapter.ClientID %>');

             if (evtType != "mouseout") {

             ddl.title = obj.options[obj.selectedIndex].value;

             }            

 

        }

 

    </script>

 

 

----------------------******************------------------------------

Javascript Access CBL Inside a Datalist

Question: How to Unselect the Chack Box Lists other that what i selected now. These check Box Lists are Items os a DataList. I want to to it in Client side.

Answer:

 

In code behind: 

    protected void dlQuestion_PreRender(object sender, EventArgs e)

    {      

 foreach (DataListItem dlItem in dlQuestion.Items)

        {

            string RadiobuttonListIdsWithoutCurrentRBL = string.Empty;

 

            RadioButtonList rdblChapterQuestions = (RadioButtonList)dlItem.FindControl("rdblChapterQuestions");

 

            RadiobuttonListIdsWithoutCurrentRBL = RadiobuttonListIds.Replace(rdblChapterQuestions.ClientID + ",", "");

 

            RadiobuttonListIdsWithoutCurrentRBL = RadiobuttonListIdsWithoutCurrentRBL + rdblChapterQuestions.ClientID;

 

            foreach (ListItem li in rdblChapterQuestions.Items)

            {

                //javascript:RemoveRadioButtonSelect(" + RadiobuttonListIdsWithoutCurrentRBL + ")

                li.Attributes.Add("onclick", "RemoveRadioButtonSelect('" + RadiobuttonListIdsWithoutCurrentRBL + "');");

 

            }

       }

  }

  //li.Attributes.Add("onclick", "RemoveRadioButtonSelect(" + RadiobuttonListIdsWithoutCurrentRBL + ")");

 

//RadiobuttonListIdsWithoutCurrentRBL => string will give all radiobutton ids to be unchecked.

 

 

 

In mark up page:

 

 

<script language="javascript" type="text/javascript">

 

        function RemoveRadioButtonSelect() {

 

            //RemoveRadioButtonSelect.arguments will give all the arguments passing through this RemoveRadioButtonSelect()

            var argv = RemoveRadioButtonSelect.arguments;

 

            var argc = argv.length;

 

            for (var i = 0; i < argc; i++) {

            //  will get the RadioButtonList Ids One by One

                var radioButtonListId = document.getElementById(argv[i].id);

 

                if (radioButtonListId != null) {

            // will get the input tags of the RBL.

                    var objListItem = radioButtonListId.getElementsByTagName('input');

 

 

                    for (var itemCount = 0; itemCount < objListItem.length; itemCount++) {

            //Looping through the all input tags of RBL

                        objListItem[itemCount].checked = false;

                    }

                }

            }

        }

 

</script>

 

 

-------------*********************************--------------

 

ABS in TVS 2-wheelers

The Chennai-based TVS Motors is all set to become the first global company to launch anti-lock brake system (ABS) on its two wheelers.

ABS, often referred as a ‘sure braking system’ for automobiles, is a high-tech feature and is currently available in all premium four wheelers and commercial vehicles across the globe. It is gaining immense popularity in India and comes as a standard fitment in all premium cars and high-end trucks and buses.

TVS is currently testing the indigenously developed ABS technology on its bikes and scooters to reduce multiple vehicle and the run-of-road crashes. A senior executive of TVS Motors confirmed that the technology in the final stages of development and is undergoing testing at its Hosur facility. “ABS is part of the 30 different technologies we are developing for our two -wheeler range.

The ABS will help in avoiding skidding of two-wheelers and allow sure stopping on wet and slippery roads and help in reducing fatalities on two wheelers,” the executive said. ABS technology reduces chances of crashing, and the severity of impact. It significantly reduces the chances of a skid and subsequent loss of control by the driver on the vehicle. On slippery surfaces it leads better control of the vehicle rather than go into a skid as it instantly locks the multiple wheels of the vehicle.

Working on the same concept, the ABS is likely to be introduced initially on yet to be launched high powered bikes of TVS in the premium 200 cc segment

But i'm gonna get my RTR 160 eFI now.. i dono how much time they will take to release this.. and whether they are going to fit this ABS with 160 eFI.. So i dont want to wait for this ABS.. I'm gonna get this RAT 160 eFI today....

!!!!!!!!!!!!!!!!!!!!!!!!!!!  wooooohoooooooooooooo  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

 

----------------------------*************************------------------------------------

RTR 160 eFI

 

Next week i might own RTR 160 eFI..

To make ur EFI a constant MILEAGE producer , u must do the following

1). never n ever change the tyre , which will reduce the fixed mileage of the vehicle . the more broad the tyre is , the less mileage it gives

2). CHANGE UR ENGINE OIL REULARLY FOR EXACTLY ABOUT EVERY 1500km OF INDICATION . ( U MAY CHANGE ENGINE OIL EVEN FOR EVERY 2000KM if it is an issue for u to change for every 1500km )

3). GIVE UR EFI TO AN AUTHORISED SERVICE CENTRE EXACTLY FOR EVERY 2000KM OF USAGE

if u follow these 3 things regularly , then I ASSURE U THAT ur EFI will NOT give u less mileage even after 10years of usage…

 

 

No choke and even in hilly regions even during winters it will start without a whimper form total cold start. 

There is no reserve option in this and minimum 3 litres will have to be kept reserve in the tank.

Features:

1) Air Scoop is available to cool your engine quick.

2) Rear Disc Break will make the bike riding more controlled on your own..

3) Of course, Fuel injection. There is no carburetor.. Instead of that u have Electronic Fuel Injector will give u more millage.

4) It is a 4 stoke engine.

5) max Power 15.7 bhp at 8500 rpm.

6) Transmission : 5 gears

7) Digital speedo meter.

8) Clips on Handle bar. it will give you more grip.

 

-------------------------------*************************---------------------------------


 


 

 

 

 

Remove Tab Characters In SQL

 

it is same like removing new line characters what i have mentioned in my previous post..

To remove tab characters in T-SQL I wrote the following SQL script (TODO: write  re-usable SP, also special option to remove Tab characters from the end of the string)


declare @tab char(1)

set @tab=char(9)

update HSCodeLookup

     set DescForQuery =Replace(DescForQuery , @tab,' ')

WHERE DescForQuery like '%' +@tab +'%';

 


Note that even if WHERE condition may  look redundant,  it is important for performance. Without the (ColumnName like '%' +@Tab +'%')condition all records will be updated,even if actual column value would not be changed.

 

  ---------------*************************---------------

 

Remove New Line Characters In SQL

I found that some string in the database have NewLine characters where they do not required?

If above is your question, you can get the answer below...


To remove them in T-SQL I wrote the following SQL script (TODO: write  re-usable SP, also special option to remove NewLine characters from the end of the string)

declare @NewLine char(2)

set @NewLine=char(13)+char(10)

update TableName

     set ColumnName =Replace(ColumnName , @NewLine,'')

WHERE ColumnName like '%' +@NewLine +'%'


Note that even if WHERE condition may  look redundant,  it is important for performance. Without the (ColumnName like '%' +@NewLine +'%')condition all records will be updated,even if actual column value would not be changed..
..Thats It.....

----------------------*****************----------------------

 

Find controls in RowCommand event of a GridView

First we have to know which button making the command. It may be Button, ImageButton, LinkButton etc..

 

the code following is for linkbutton making a command "updat".

protected void GridView6_RowCommand(object sender, GridViewCommandEventArgs e)

    {

if (e.CommandName == "updat")

        {

    //finding row where the command coming from...            

    GridViewRow row = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer); 

            Label  UID = (Label)row.FindControl("Label1");

            Label  AgencyName = (Label)row.FindControl("Label2");     

            Response.Redirect("AddPackage.aspx?PackageId=" + e.CommandArgument + "&UserId=" + UID.Text + "&AgencyName=" + AgencyName.Text);

       

    }