Tuesday, September 27, 2016

How to set dropdown value by text using jquery

This is just a quick post to show how to set dropdown value by text using jquery.

This is a method that works based on the text of the option, not the index.

 
$("#YourDropDownId option").each(function() {
  if($(this).text() == TextToBeDisplayOrSelected) {
    $(this).attr('selected', 'selected');            
  }                        
});


Special Thanks To : 

Thursday, July 2, 2015

How to get image URL via C# from site-core

This is just a quick post to show how to get image URL via code behind C#.

This is mostly useful when you are binding children items to a repeater or returning image URL in a JSON web-service.

 public static string GetImageURL(Item currentItem)  
 {  
      string imageURL = string.Empty;  
      Sitecore.Data.Fields.ImageField imageField = currentItem.Fields["Image"];  
      if (imageField != null && imageField.MediaItem != null)  
      {  
       Sitecore.Data.Items.MediaItem image = new Sitecore.Data.Items.MediaItem(imageField.MediaItem);  
       imageURL = Sitecore.StringUtil.EnsurePrefix('/', Sitecore.Resources.Media.MediaManager.GetMediaUrl(image));  
      }  
 return imageURL;  
 }  


Special Thanks To : 

Thursday, March 12, 2015

HTML Button onserverclick fired twice in ASP.NET UpdatePanel

Old Code:
 

New Code:
Just change button type to button from submit and issue is resolved.

Tuesday, June 16, 2009

To Create a DropDownList from an ENUM

You have an 'Enum' defined as follows:
public enum CompanyAddressType
{
Unknown = 0,
Primary = 1,
Warehouse = 2,
Distribution_Center = 3,
Cross_Dock = 4
}


You want to iterate through the list and put the data into an asp.net DropDownList.

Here is the simple code:


protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string[] names = Enum.GetNames(typeof (CompanyAddressType));
var values = (CompanyAddressType[]) Enum.GetValues(typeof (CompanyAddressType));
for (int i = 0; i < names.Length; i++)
{
DropDownListCompanyAddressType.Items.Add(new ListItem(names[i], values.ToString()));
}
}
}

There are probably easier ways to do it, but this works.


Use the tips!

Saturday, May 23, 2009

ஜிமெயில் ஷார்ட் கட் கீகள்


உங்களுடைய ஜிமெயில் அக்கவுண்ட்டை மவுஸ் கொண்டு செலுத்துவதற்குப் பதிலாக கீ போர்டு ஷார்ட் கட் கீகள் மூலம் செயல்படுத்தலாம். இந்த கீ போர்டு ஷர்ர்ட் கட் கீகளைப் பயன்படுத்துவதனால் நம் நேரம் மிச்சமாகிறது. மேலும் கீ போர்டிலிருந்து கைகளை எடுக்காமல் விரைவாக நம்மால் செயல்பட முடியும்.

இதோ சில ஷார்ட் கட் கீகள்:

F : கீயை மட்டும் அழுத்தினால் இமெயில் செய்தியை அடுத்ததற்கு பார்வேர்ட் செய்திட முடியும்.

/: சர்ச் பாக்ஸில் உங்கள் கர்சரை நகர்த்த

Shift+l : இமெயில் மெசேஜைப் படித்ததாக குறியீடு செய்வதற்கு

Shift+u : இமெயில் மெசேஜைப் படிக்காததாகக் குறியிட

r : மெயிலை அனுப்பியவருக்கு பதில் அனுப்ப.

u : உங்களுடைய இமெயில் அக்கவுண்ட்டை ரெப்ரெஷ் செய்து லேட்டஸ்டாக வந்த இமெயில் மெசேஜை காண

a : அனைத்து மெயில் பெற்றவர்களுக்கும் பதில் அனுப்ப

ctrl+c
: அப்போதைய இமெயிலை ட்ராப்டாக சேவ் செய்திட

Z : முந்தைய செயல்பாட்டை கேன்சல் செய்திட

? : கீ போர்டு ஷார்ட் கட் கீகள் குறித்த உதவிக் குறிப்புகளைக் காட்ட

c : புதிய இமெயில் மெசேஜ் ஒன்றை எழுதிட

! : இமெயில் மெசேஜ் ஒன்றை ஸ்பாம் மெயிலாகக் குறிப்பிட

p : தற்போதைய மெயிலுக்கு முன் உள்ள மெயிலுக்குச் செல்ல

. : வெறும் புள்ளி அடித்தால் கூடுதலான ஆப்ஷன்ஸ் காட்டப்படும்.

Esc : கர்சரை தற்போதைய பீல்டிலிருந்து நகர்த்தும்.

இந்த பதிவினை படிக்கும் நீங்கள் மறக்காமல் உங்கள் கருத்துகளை என்னிடம் தெரிவிக்கலாம். உங்கள் கருத்துகளுக்காக காத்திருக்கும் நண்பன் - ரங்கோலி.

Tuesday, May 12, 2009

SQL SERVER – How to Drop Primary Key Contraint from a Table

First, we will create a table that has primary key. Next, we will drop the primary key successfully using the correct syntax of SQL Server.

CREATE TABLE Table1(
Col1 INT NOT NULL,
Col2 VARCHAR(100)
CONSTRAINT PK_Table1_Col1 PRIMARY KEY CLUSTERED (
Col1 ASC)
)
GO

Second, try to drop the primary key constraint using following lines.

/* For SQL Server/Oracle/MS ACCESS */
ALTER TABLE Table1
DROP CONSTRAINT PK_Table1_Col1
GO
/* For MySql */
ALTER TABLE Table1
DROP PRIMARY KEY
GO


Use the tips!!!

Thursday, April 23, 2009

Java Script : 'toFixed' Math function to format number

<div style="text-align: justify;">We can use 'toFixed()' function in math to format a number upto required decimal places. The value we get is after rounding the number upto the decimal place required. This function is frequently used in java script. </div>

Here is the sample syntax.
my_val.toFixed(4)
my_val is the variable which stores the number. Here we are formatting the number upto 4 decimal places.

Let us try with some examples with different number values.
var my_val=11.257;
document.write (my_val.toFixed(2)); // output 11.26

var my_val=11.25;
document.write (my_val.toFixed(1)); // output 11.3

var my_val=11.978;
document.write (my_val.toFixed(4)); // output 11.9780

Use the tips!

Tuesday, March 31, 2009

Time Management

Time Management

In my profile, I mentioned as one of my strength is "Goal Setting". What is goal setting? We should plan our Day,Week & Month well before. As we plan we could achieve our goals. Just planning alone will not lead to complete our goals, we should implement it as per our plan. Time is most important here. If you plan half an hour for a job, you should try to finish it as you planned. First time it may not be possible, but when you practice it in your day today activities, it becomes your routine. After some time, you could finish it even before time.

Day Plan :-
  1. Create a simple "To do" list for that particular day
  2. This simple "To do list" will help us to identify the list of items to be completed in that particular day.
  3. List to be prepared as priority, and we could give reason for doing them in priority
  4. A timeline for getting them done, and then printing this simple list and posting it for reminders.
  5. This reminders we could set in our outlook.


Week Plan :-
  1. Write down appointments, classes, training and meetings on a log book or chart.
  2. If you are more visual, sketch out your schedule
  3. First thing in the morning, check what's ahead for the day
  4. Always go to sleep knowing you're prepared for tomorrow


Long term plan :-
  1. Use a monthly chart so that you can plan ahead.
  2. Long term planners will also serve as a reminder to constructively plan time for yourself


All the above can be done for home also... not a big deal right !!

Try for a day plan... reminders.... updates.! You will realise the change on you and your work and also how quick you reach home when you plan your day.

Happy Timing!

Corporate Dress Code

Corporate Dress Code

Corporate dressing is a powerful tool in the office space. The manner in which you present yourself projects not only your personality but the image of the company too. Appropriate dress and grooming has a profound impact on co-workers as well as external customers.

Dress Code Male:
- Do’s

1. Half /Full sleeve shirt with Tie
2. Black/Brown Shoes

- Dont’s

1. Loud Design/Colour Shirts
2. Sports Shoes
Dress Code Female:
- Do’s

1. Salvar /Saree’s
2. Black/ Brown - Shoes / Chappal

- Dont’s

1. Tight Dresses and Sleeveless tops.
2. Jeans Pants, t-shirts with logos / Letters
3. Wearing too much Jewellery
4. Noisy bracelets, Bangles
Dress Down Days :-
Do’s - Casuals wrinkle-free, in good repair, and pulled together with Unifying elements like matching belts and shoes.

Happy Dresssing!

Wednesday, March 25, 2009

WCF Performance: Making your service run 3 times faster

Wisely changing WCF defaults can yield a significant improvement in your service performance. The exact changes need to be made and their exact effect are dependent in the scenario. The example below how to speed up a certain service 3 times faster.
Read more at http://webservices20.blogspot.com/2009/01/wcf-performance-gearing-up-your-service.

Happy Coding!