Adding MetaKeyword and MetaDescription Using Page object.Meta keywords and description are most important components of a page when we want to make it search engine friendly. Every search engine will look for these tags to know more information of the page contents. ASP.Net 2.0 introduced a new feature where one can add these tags from the code behind using HtmlMeta class. It would have been better if we are able to do this through Page directive (Page class). ASP.Net 4.0 added 2 new properties on the Page object to let you define the Meta keywords and Description.
Refer the code below,
protected void Page_Load(object sender, EventArgs e){
Page.MetaKeywords = "asp.net,C#";
Page.MetaDescription = "This is an asp.net site that hosts asp.net tutorials.";
}
OR
<%@ Page Language="C#" AutoEventWireup="true" MetaKeywords="asp.net,C#" MetaDescription="This is an asp.net site that hosts asp.net tutorials" CodeFile="Default.aspx.cs" Inherits="_Default" %>
The above code will add the meta tags in the output html.
Note
We can still do this in earlier version by defining a BasePage class.
Enabling Viewstate for Page level and control level:
ViewState is one of the important factors if we start looking at improving the performance our asp.net site. Till ASP.Net 3.x, we have EnableViewState property both at Page level and server control level to control the view state. Disabling the ViewState at page level will disable the viewstate to all the page controls. In order to improve the performance, one need to switch off the viewstate for individual control for which saving the viewstate is not necessary and hence disabling viewstate at page level is not a suitable option. To overcome this difficulty, asp.net 4.0 added a new property to Page object and controls called ViewStateMode.
This property can take 3 values:
With this property, we can disable the viewstate for the page and enable it for the control if only required.
Consider the following code,
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ViewStateTest.aspx.cs" ViewStateMode="Disabled" Inherits="ViewStateTest" %>
|
Wednesday, July 14, 2010
New Features in ASP.Net 4.0 - PART 1
Tuesday, June 15, 2010
Monday, May 3, 2010
How Web service create Proxy and dll Using WSDL?
- HTTP GET
- HTTP POST
- SOAP.
- Generate a Proxy for the Web Service
- Compile the Proxy as a DLL library
- Create a Visual C# - Console Application Project
OR
WSDL /out:myProxyClass.cs http://hostServer/WebserviceRoot/WebServiceName.asmx?WSDL
- Create a new Visual C# console application in order to consume web service and add a reference to the already created DLL(based on point no.1 & 2).
- We create an instance of the proxy class and call functionality wherever required.
- Build the project file and run the client.
Thursday, April 29, 2010
Difference Between URI and URL
e.g.- products/books/detail.html
It is not a URL because it does not specify how to retrieve the resource.
URL – http://www.xyz.com/products/books/detail.html
is a URL because it specifies how to retrieve the resource
URN- e.g. ISBN:1-9211009-59 is a URN because it uniquely identifies this book.
We can get this to use following code :
System.out.println(“URI : “+ httpRequestObj.getRequestURI());
System.out.println(“URL : “+ httpRequestObj.getRequestURL());
IN vs Exists
Returns true if a specified value matches any value in a subquery or a list.
Exists:
Returns true if a subquery contains any rows.
What is INDEX ?
For e.g. There are thousands of records in a table, retrieving information will take long time. Therefore Index has created on column which are accessed frequently. So that the information able to retrieve quickly. Index can be created on a single column or group of columns. When index is created, it first sort the data and then it assigns RowId for each row.
Syntax :
CREATE INDEX index_name ON table_name (column_name1,column_name2...);There are two type of index available
in sql namely like1.Clustered Indexes2.Non clustered IndexClustered Index :
It can be created using "create index ..." syntax.
Non Clustered Indexes :
They are created when a column is explicitly defined with PRIMARY KEY, UNIQUE KEY Constraint which is not based on sorted record but on a bookmark.
Note:
1) Even though sql indexes are created to access the rows in the table quickly, they slow down DML operations like INSERT, UPDATE, DELETE on the table, because the indexes and tables both are updated along when a DML operation is performed. So use indexes only on columns which are used to search the table frequently.
2) If we have less data, not required to create indexes.
3) In oracle database you can define up to sixteen (16) columns in an INDEX.
Monday, April 5, 2010
10 Deadly Sins of Negative Thinking
Life could be so much better for many people, if they would just spot their negative thinking habits and replace them with positive ones.
Negative thinking, in all its many-splendored forms, has a way of creeping into conversations and our thinking without our noticing them. The key to success, in my humble opinion, is learning to spot these thoughts and squash them like little bugs. Then replace them with positive ones. You’ll notice a huge difference in everything you do.
Let’s take a look at 10 common ways that negative thinking emerges — get good at spotting these patterns, and practice replacing them with positive thinking patterns. It has made all the difference in the world for me.
10 Deadly Sins of Negative Thinking
1. I will be happy once I have _____ (or once I earn X).
Problem: If you think you can’t be happy until you reach a certain point, or until you reach a certain income, or have a certain type of house or car or computer setup, you’ll never be happy. That elusive goal is always just out of reach. Once we reach those goals, we are not satisfied — we want more.
Solution: Learn to be happy with what you have, where you are, and who you are, right at this moment. Happiness doesn’t have to be some state that we want to get to eventually — it can be found right now. Learn to count your blessings, and see the positive in your situation. This might sound simplistic, but it works.
2. I wish I were as ____ as (a celebrity, friend, co-worker).
Problem: We’ll never be as pretty, as talented, as rich, as sculpted, as cool, as everyone else. There will always be someone better, if you look hard enough. Therefore, if we compare ourselves to others like this, we will always pale, and will always fail, and will always feel bad about ourselves. This is no way to be happy.
Solution: Stop comparing yourself to others, and look instead at yourself — what are your strengths, your accomplishments, your successes, however small? What do you love about yourself? Learn to love who you are, right now, not who you want to become. There is good in each of us, love in each of us, and a wonderful human spirit in every one of us.
3. Seeing others becoming successful makes me jealous and resentful.
Problem: First, this assumes that only a small number of people can be successful. In truth, many, many people can be successful — in different ways.
Solution: Learn to admire the success of others, and learn from it, and be happy for them, by empathizing with them and understanding what it must be like to be them. And then turn away from them, and look at yourself — you can be successful too, in whatever you choose to do. And even more, you already are successful. Look not at those above you in the social ladder, but those below you — there are always millions of people worse off than you, people who couldn’t even read this article or afford a computer. In that light, you are a huge success.
4. I am a miserable failure — I can’t seem to do anything right.
Problem: Everyone is a failure, if you look at it in certain ways. Everyone has failed, many times, at different things. I have certainly failed so many times I cannot count them — and I continue to fail, daily. However, looking at your failures as failures only makes you feel bad about yourself. By thinking in this way, we will have a negative self-image and never move on from here.
Solution: See your successes and ignore your failures. Look back on your life, in the last month, or year, or 5 years. And try to remember your successes. If you have trouble with this, start documenting them — keep a success journal, either in a notebook or online. Document your success each day, or each week. When you look back at what you’ve accomplished, over a year, you will be amazed. It’s an incredibly positive feeling.
5. I’m going to beat so-and-so no matter what — I’m better than him. And there’s no way I’ll help him succeed — he might beat me.
Problem: Competitiveness assumes that there is a small amount of gold to be had, and I need to get it before he does. It makes us into greedy, back-stabbing, hurtful people. We try to claw our way over people to get to success, because of our competitive feelings. For example, if a blogger wants to have more subscribers than another blogger, he may never link to or mention that other blogger. However, who is to say that my subscribers can’t also be yours? People can read and subscribe to more than one blog.
Solution: Learn to see success as something that can be shared, and learn that if we help each other out, we can each have a better chance to be successful. Two people working towards a common goal are better than two people trying to beat each other up to get to that goal. There is more than enough success to go around. Learn to think in terms of abundance rather than scarcity.
6. Dammit! Why do these bad things always happen to me?
Problem: Bad things happen to everybody. If we dwell on them, they will frustrate us and bring us down.
Solution: See bad things as a part of the ebb and flow of life. Suffering is a part of the human condition — but it passes. All pain goes away, eventually. Meanwhile, don’t let it hold you back. Don’t dwell on bad things, but look forward towards something good in your future. And learn to take the bad things in stride, and learn from them. Bad things are actually opportunities to grow and learn and get stronger, in disguise.
7. You can’t do anything right! Why can’t you be like ____ ?
Problem: This can be said to your child or your subordinate or your sibling. The problem? Comparing two people, first of all, is always a fallacy. People are different, with different ways of doing things, different strengths and weaknesses, different human characteristics. If we were all the same, we’d be robots. Second, saying negative things like this to another person never helps the situation. It might make you feel better, and more powerful, but in truth, it hurts your relationship, it will actually make you feel negative, and it will certainly make the other person feel negative and more likely to continue negative behavior. Everyone loses.
Solution: Take the mistakes or bad behavior of others as an opportunity to teach. Show them how to do something. Second, praise them for their positive behavior, and encourage their success. Last, and most important, love them for who they are, and celebrate their differences.
8. Your work sucks. It’s super lame. You are a moron and I hope you never reproduce.
Problem: I’ve actually gotten this comment before. It feels wonderful. However, let’s look at it not from the perspective of the person receiving this kind of comment but from the perspective of the person giving it. How does saying something negative like this help you? I guess it might feel good to vent if you feel like your time has been wasted. But really, how much of your time has been wasted? A few minutes? And whose fault is that? The bloggers or yours? In truth, making negative comments just keeps you in a negative mindset. It’s also not a good way to make friends.
Solution: Learn to offer constructive solutions, first of all. Instead of telling someone their blog sucks, or that a post is lame, offer some specific suggestions for improvement. Help them get better. If you are going to take the time to make a comment, make it worth your time. Second, learn to interact with people in a more positive way — it makes others feel good and it makes you feel better about yourself. And you can make some great friends this way. That’s a good thing.
9. Insulting People Back
Problem: If someone insults you or angers you in some way, insulting them back and continuing your anger only transfers their problem to you. This person was probably having a bad day (or a bad year) and took it out on you for some reason. If you reciprocate, you are now having a bad day too. His problem has become yours. Not only that, but the cycle of insults can get worse and worse until it results in violence or other negative consequences — for both of you.
Solution: Let the insults or negative comments of others slide off you like Teflon. Don’t let their problem become yours. In fact, try to understand their problem more — why would someone say something like that? What problems are they going through? Having a little empathy for someone not only makes you understand that their comment is not about you, but it can make you feel and act in a positive manner towards them — and make you feel better about yourself in the process.
10. I don’t think I can do this — I don’t have enough discipline. Maybe some other time.
Problem: If you don’t think you can do something, you probably won’t. Especially for the big stuff. Discipline has nothing to do with it — motivation and focus has everything to do with it. And if you put stuff off for “some other time”, you’ll never get it done. Negative thinking like this inhibits us from accomplishing anything.
Solution: Turn your thinking around: you can do this! You don’t need discipline. Find ways to make yourself a success at your goal. If you fail, learn from your mistakes, and try again. Instead of putting a goal off for later, start now. And focus on one goal at a time, putting all of your energy into it, and getting as much help from others as you can. You can really move mountains if you start with positive thinking.