Saturday, August 23, 2008

Interviews Tips and Advices

Some stuff you should do in the Interviews:

1 - Arrive on time or early but not too early.
2 - Dress formally, this would give you a self-confident.
3 - Be polite to everyone in the office.
4 - Act confident, but not overconfident.
5 - Give the appearance of energy as you walk.
6 - Don't forget to Smile.
7 - Shake hands firmly and stand until offered a chair.
8 - Look to the interviewer in the eye while speaking.
9 - If the interviewer ask you to fill an application do it and finish it all.
10 - Listen carefully, this would help you finding the best answers.
11 - Take your time and think carefully before answering any question.
12 - Make sure that your good points come across to the interviewer in a factual, sincere manner.
13 - Always conduct yourself as if you are determined to get the job you are discussing.
14 - Stress your achievements.
15 - Finaly don't forget to thank the interviewer for interviewing you.

Some stuff you should not do in the Interviews:

1 - Don’t be late or overdressed.For women wear only light perfume, make up, and jewelry.
2 - Don't forget to bring a copy of your resume!
3 - Don't smoke or chew gum, even if the interviewer does and offers you either.
4 - Don't answer with a simple "yes" or "no".
5 - Don’t over-answer questions or talk too much either.
6 - Don't lie. Answer questions truthfully, frankly, and briefly.
7 - Don't make derogatory remarks about your present or former employers and co-workers.
8 - Don’t mention other companies that turned you down.
9 - Don't inquire about salary, vacations, etc. during the first interview unless you are sure the employer is interested in hiring you.
10 - Don’t take anyone with you to the interview.
11 - Don’t apologize for lack of experience or training; stress your strong points instead.
12 - Don’t put anything on the interviewer's desk.
13 - Don’t try to be very funny.
14 - Don’t hang around after the interview.
15 - Don’t make elaborate promises.

Thursday, August 21, 2008

How to Add static item to the top of DropDownList ASP.NET Web Control after biniding it

Sometimes you need to add a static item to the top of DropDownList ASP.NET Web Control, Such as "----" or "Select" or any other text.

If you add it in the design time you would see it but when you run the web site this item would be removed and replaced with the items that comes from the Data Source that you are using for binding.

In order to keep the static item, set the "AppendDataBoundItems" property of the DropDownList to "True".

Tuesday, August 19, 2008

How to Ignore JavaScript errors

Sometimes when you are working on a page and want to publish it and you have some JavaScript errors, but you don't have time to debug it, you can put the following code in order to ignore the JavaScript errors:

<head>
<script language="javascript">
    function stoperror() {
        return true;
    }
    window.onerror = stoperror();
</script>
</head>

Sunday, August 17, 2008

How to Solve this error "The GridView 'MyGridview' fired event PageIndexChanging which wasn't handled."

You can see this error when you are populating a Gridview with code, and you enabled the Paging Property of the Gridview without implementing the PageIndexChanging Event.

So when you click the next Page in the Gridview you will see this error:

"The GridView 'MyGridview' fired event PageIndexChanging which wasn't handled."

To avoid this issue simply write this code in the PageIndexChanging Event:

MyGridview.PageIndex = e.NewPageIndex;
MyGridview.DataBind();

Friday, August 15, 2008

How to Use Response Object in a Class

If you try to use


Response.Write(MyString);

Method for example in a class you will receive an error telling you that the Response Object is not available in this context.

In order to use the Response Object in a class without having this error, instead of writing

Response.Write(MyString);

write this

HttpContext.Current.Response.Write(MyString);

Or you can use any method of the Response Object.

And don't forget to write Using System.Web in the top of the class.

Wednesday, August 13, 2008

How to Replace a text in SQL Server Table Column

If you have a Table which has a Column of type char or varchar or even text, and you want to change a portion of text in it for example a path.
In this case you need to change the same text with new one in every records.

Here is the SQL Statement that do this:

UPDATE [TableName] SET [ColumnName] = Replace([ColumnName],'OldText','NewText');

Monday, August 11, 2008

How to Change the file size in FileUpload control

I tried to upload file using FileUpload Control in ASP.NET but I had a problem which is the maximum file size is 4 MB, and I was uploading a file larger than the maximum size.
So to solve this problem, in the HTTPRuntime section in the Web.config file set the maxRequestLength in KB:

<system.web>
  <httpRuntime maxRequestLength="1500000" />
</system.web>

Saturday, August 9, 2008

Confirmation Messagebox when deleting an item from the GridView ASP.NET Control

Many Users click the delete button within the GridView with no attention then the result the item will be deleted from the GridView, so we can add confirmation messagebox to appear to tell the user "Are you sure you want to delete this item?".

First of all we have to attach the javascript code for each delete button within the GridView, we can do that in the itemdatabound method of the GridView:

HttpContext.Current.Response.Write(MyString);
LinkButton deleteButton = e.Item.Cells[0].Controls[0];
deleteButton.Attributes.Add("onclick","javascript:return confirm('Are you sure you want to delete this item?')");

where the first cell in the GridView is a linkbutton.
So when the user clicks the delete button then a confirmation message appears so if the user clicks No then nothing happens else postback will happen then it should be a server event such as a onDeleteCommand that fires when the user clicks the delete button as

private void dgPendingCompleteForms_Delete(Object sender, DataGridCommandEventArgs e)
{
    //Put your code here when the user presses the yes button on the confirmation meessagebox
}

Thursday, August 7, 2008

The string function "EndsWith" is case-sensitive

Did you know that "EndsWith" String function is case-sensitive even in VB.NET?

You need to make sure you are looking for the correct string, since 'abc' with case-sensitivity is different than 'ABC'.

So, if your function is looking for 'abc', you must make sure that you make adjustments to the string, in order to catch things like this.

To do this, you would need to change:


myString.EndsWith("abc");

to

myString.ToLower.EndsWith("abc");

Tuesday, August 5, 2008

Password Recovery Web Control cannot send email Via SSL Mail Servers

I was using lately the Login Controls in a Website I am working on it, and I discovered a bug or you can call it limitation in Password Recovery Web Control. I used to use the Membership provider and Login Controls, but I didn't face this problem before since I was send the email via Non SSL Enabled SMTP server.

Now I was trying to send email using Password Recovery Control via Gmail, I got this error:

The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first. 32sm15616652wfa.13 Password Recovery control read most of the settings from web.config file.

Internally it uses System.Net.Mail to send out email, which does not support reading EnableSSL setting from web.config. This bring us into a situation where Password Recovery control cannot send emails to SSL enabled smtp servers.

This because there is no settings in the Web.Config file for System.Net.Mail (.NET 2.0) that maps to EnableSSL Property of System.Net.Mail.SmtpClient.

Here is the solution for this problem:

1- We will consume the SendingMail Event.
2- This provide us access to the Email Message being sent and also give us option to cancel the sending operation.
3- We Will make a copy of this email message, and create a new instance of System.Net.Mail.SmtpClient
4- This time we have complete access to its properties and we can turn On/Off the EnableSSL setting
5- Lets set EnableSSL to true and send the email message to desired SMTP server.

The below code snippet can do the job:


protected void PasswordRecovery1_SendingMail(object sender, MailMessageEventArgs e)
{
    System.Net.Mail.SmtpClient smtpSender = new System.Net.Mail.SmtpClient("smtp.google.com", 587);
    smtpSender.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
    smtpSender.Credentials = new System.Net.NetworkCredential("username@gmail.com", "password");
    smtpSender.EnableSsl = true;
    smtpSender.Send(e.Message);
    e.Cancel = true;
}

Sunday, August 3, 2008

Change the back color of a Gridview row when you click the Edit button or link

If you have an editable Gridview and you need to change the backcolor of the row you are editing, just write these tow lines of code in the Gridview's RowEditing Event.

MyGridview.SelectedIndex = e.NewEditIndex;
MyGridviewID.SelectedRow.BackColor = Drawing.Color.Red;

Friday, August 1, 2008

Some Stuff You Should Know About Windows XP - Part2

To see part 1 Click Here

6 - Non-expired password for all users

If you want to make the password never expire for all the users type this in DOS Prompt
net accounts /maxpwage:unlimited 7-Cancellation folder "Shared Documents"
If you want to remove the Shared Documents Folder that show for all the users with the LAN do the following:

a-Go to Start -> Run -> regedit -> Enter
This would open the Registry editor for you.
b- Go to HKEY _CURRENT_USER -> Software -> Microsoft -> Windows -> CurrentVersion ->Policies -> Explorer
c-Create new Value and choose DWORD type for this value.
d-Name this Value NoSharedDocuments and give it 1 as Value.

7 - Change the Programmes that run in the sartup

Go to Satart -> Run -> msconfig then press enter. This would open the System Configuration Utility for you.

Go to Startup Tab and choose which programmes do you like to start when windows start and which programmes not.

8 - Administrative Tools Programes

For unknown reason there are some programes should be in the Administrative Tools Folder in Control Panel but it just not there.

In order to use it type this in Run:

Computer Management - compmgmt.msc Disk Managment - diskmgmt.msc Device Manager - devmgmt.msc Disk Defrag - dfrg.msc Event Viewer - eventvwr.msc Shared Folders - fsmgmt.msc Group Policies - gpedit.msc Local Users and Groups - lusrmgr.msc Performance Monitor - perfmon.msc Resultant Set of Policies - rsop.msc Local Security Settings - secpol.msc Services - services.msc Component Services - comexp.msc

9 - How to add NetBEUI Protocle

Some poeple belive that NetBEUI Protocl don't work with Windows XP. The fact is this protocl don't come dirctly with Windows Xp in order to use it do the following:

a-Go to VALUEADD -> MSFT -> NET -> NETBEUI in the Windows XP Installation CD
b-Copy NBF.SYS file to WINDOWS -> SYSTEM32 -> DRIVERS
c-Copy NETNBF.INF file to WINDOWS -> INF
d-From the LAN properties you can now use NetBEUI Protocol like any other one.

To see part 1 Click Here

Hire Me

Follow me on Facebook

Follow me

Do you find this Blog helpful?

Follow by Email

About Me

My Photo
Expert Senior Software Developer

Microsoft Business Card