Friday, May 28, 2010

How to initiate a JavaScript function after an Ajax post back or Page load?

The below code will explain you how to call a function after an Ajax post back using Sys.Application.add_load.you can hook a fuction to this evvent with will be called after a page is loaded after ajax postback.
 

How to select an item in a dropdown (combobox) by its values using JavaScript?

You can select an item a by its values using the below code.


You can also get more information regarding various function and propertied of a dropdown (combobox) from the below link. http://www.navioo.com/javascript/dhtml/Changing_Select_Element_Content_two_Combobox_2755.html

How to get the selected values of dropdown (combobox) using JavaScript?

The selected values of a dropdown (combobox) can be accessed by the values and text property of a dropdown’s (combobox) option object.

The option object has the following properties.

defaultSelected          Refers to the option that is selected by
                                 default from the select box.

index                         Refers to the zero-based indexed location
                                of an element in the Select.options array.

selected                     Refers to the selected value of
                                 the select box.

text                            Refers to the text for the option.

value                          Refers to the value that is returned
                                  when the option is selected.

Accessing the value of a dropdown (combobox) is shown in the below example.


You can also get more information regarding various function and propertied of a dropdown (combobox) from the below link.
http://www.navioo.com/javascript/dhtml/Changing_Select_Element_Content_two_Combobox_2755.html

Thursday, May 27, 2010

Date Functions in Java Script?

To handle the date time function in javascript ,i sugesst to use the pre coded fucntion in the web site below.You can use the function in the below site free of cost in your code.

Thre are also other usefull javascript function in this site.

http://www.mattkruse.com/javascript/date/

Thursday, May 6, 2010

How to format a string in c# or how to use string.Format?

This String.Format method accepts a format string followed by one to many variables that are to be formatted. The format string consists of placeholders, which are essentially locations to place the value of the variables you pass into the function. These placeholders have the following format:


{indexNumber:formatCharacter}

The below code will convert 1 to 01
string.Format("{0:00}",1)

The Below code will convert a date to the format as "06/05/2010"
string.Format("{0:dd/MM/yyy}",DateTime.Now)

The Below code will convert a date to the formatas "Thursday, May 06, 2010"
string.Format("{0:D}", DateTime.Now)

The Below code will convert a date to the format as “Thursday”
string.Format("{0:dddd}", DateTime.Now)

The Below code will convert the number to currency as “"$1,234.00"”
string.Format("{0:c}", 1234)



You can find more into from the below link.
http://idunno.org/archive/2004/14/01/122.aspx

How to write conditional statement without using if key word in c# or How to use ternary operator?

The below code is a replacement of if keyword in c#  which you can accomplish by using the the conditional operator (?:)

condition ? first_expression : second_expression;

Ifyou excecute the below code it will print the value 20 .

int i = (2 > 3) ? 10 : 20;
Response.Write(i.ToString());

If we split the above code then (2 > 3) is considered as the condition, the result before : will be returned if the condition is true and the result after the : will be returned if it is false.

More Information can be out in the link below
http://msdn.microsoft.com/en-us/library/ty67wk28(VS.80).aspx

Wednesday, May 5, 2010

Have you used a condition like below in c#?


This above code will print false.
This staement can be further modified for function to return a boolen depending on the calculated values like below

The above function will also return return false if called like below.

Tuesday, May 4, 2010

How to hide a control using javascript in page_load or window.onload event?

The below code will help you to hide a control in page_laod event of javascipt.

How to get the selected text of a microsoft ajax combobox using javascript ?

The belwo example whill show you  how to get the selected text of a ajax combobox.

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).


When I sued the above code in my aspx page I was getting the eroor as .

“The Controls collection cannot be modified because the control contains code blocks (i.e. ).”
This error can be solved by just replacing the code as below .

Other wise pass the control’s clientId as a parameter to the javascript function from thes server side code.

Replace your code as below will solve the issue.

You can also find other solution in the bleow link.
http://www.west-wind.com/weblog/posts/5758.aspx

Saturday, May 1, 2010

How to Create stored procedure or View in SQL 2005 with encryption?

You can encrypt a view or an SP in SQL server 2005 by using the key work "with encryption" while creating the SP or View.


Please look into the example below.

create procedure MySp with encryption
as
begin
select * from EmailList
end

Once you created an sp or view with the above option added then it cannot be viewed by any users.if the suer tryes to view the above sp orview then it SQL server will show a message like . The text for object 'MySp' is encrypted.

One note of caution. Save the original text of the stored procedure before encrypting it, as there is no straightforward way to decode the encrypted text. One hack is to attach a debugger to the server process and retrieve the decrypted procedure from memory at runtime


Please look to the below link for how to decrypt the encrypted Sp or view.

http://www.sql-shield.com/decrypt-stored-procedure.html