Pages

Search This Blog

Saturday, October 13, 2007

remove "Yahoo Toolbar" from Firefox



Open Mozilla Firefox,
Go to Tools Menu, Click On Add-ons
A new Add-ons windows popup, Select Yahoo Toolbar and click on Unistall button.
Done

ASP.NET Cookies

Cookies is Domain dependent. Cookies created under subdomain beta.mydomain.com will not able to retrive when access to www.mydomain.com. To ensure that we can retrive the same cookies, we need to specify the domain
For example, we want to write the information to cookies under mydomain when we access to url beta.mydomain.com

HttpCookie cook = new HttpCookie("mydomain");
Response.Cookies.Clear();
Response.Cookies.Add(cook);
cook["UserId"] = userId;
cook["Name"] = username.Text;
cook.Expires = DateTime.MaxValue;
Response.Cookies.Add(cook);

To retrive the cookies information:

if (Request.Cookies["mydomain"] != null)
{
if (Request.Cookies["mydomain"]["UserId"] != null && Request.Cookies["mydomain"]["Name"] != null)
{
Session["UserId"] = Convert.ToInt32(Request.Cookies["mydomain"]["UserId"].ToString());
Session["UserName"] = Request.Cookies["mydomain"]["Name"].ToString();
}
}

Wednesday, October 10, 2007

Cannot implicitly convert type 'string' to 'System.Net.Mail.MailAddress'

I got error "Cannot implicitly convert type 'string' to 'System.Net.Mail.MailAddress' "

MailMessage msg = new MailMessage();
msg.From = "info@xxx.com";
msg.To = "comments@xx.com";
msg.Bcc = "keith@xxx.com";

msg.Subject = "Comment";
msg.Body = "Comment: xxxxxxx xxxxxxx xxxxxxx ";
SmtpClient smtpClient = new SmtpClient();
smtpClient.Host = Global.smtp;

To solve the issue, i change to below code

MailMessage msg = new MailMessage();
msg.From = new System.Net.Mail.MailAddress("info@xxx.com");
msg.To.Add("comments@xx.com");
msg.Bcc.Add("keith@xxx.com");

msg.Subject = "Comment"; msg.Body = "Comment: xxxxxxx xxxxxxx xxxxxxx ";

SmtpClient smtpClient = new SmtpClient();
smtpClient.Host = Global.smtp;

Tuesday, October 9, 2007

Could not load file or assembly 'Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of ..........

When deploy a ASP.NET application to a new server, error message below shown:

Could not load file or assembly 'Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

invoice software

Here is the scenario:
My ASP.NET App use AJAX.NET and ASP.NET AJAX Control Toolkit
My application server have NO AJAX.NET and ASP.NET AJAX Control Toolkit installed.





To solve my problem with no AJAX.NET install in my application server:

  1. Copy AjaxControlToolkit.dll and AjaxControlToolkit.pdb version 1.0.61025.0 from my development machine to my ASP.NET App bin folder. (i install my AjaxControlToolkit in C:\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\AjaxControlToolkit)

  2. Copy System.Web.Extensions.dll (C:\WINDOWS\assembly\GAC_MSIL\System.Web.Extensions) and System.Web.Extensions.Design.dll (C:\WINDOWS\assembly\GAC_MSIL\System.Web.Extensions.Design) from my development machine to my ASP.NET App bin folder.
Run the application and it's works.




Alternatively, we can solve the problem by installing AJAX.NET and AjaxControlToolkit to the server.



Wednesday, September 19, 2007

System.Web.HttpRequestValidationException: A potentially dangerous Request.QueryString value was detected from the client (xx="xxxxx")

Error Message:
System.Web.HttpRequestValidationException: A potentially dangerous Request.QueryString value was detected from the client (xx="xxxxx")


For details discussion on the .Net Request Validation
http://dotnetfish.blogspot.com/2007/08/systemwebhttprequestvalidationexception.html

Causes:
By default, .Net will validate input (Form and QueryString). Input with special tags (HTML, Javascript and etc) will cause the error message shown.


Usage for .NET Request Validation:
This validation can help to prevent "Script Injection".

To turn off the validation: (Not encourage)
<%@Page ... validateRequest="true"%> to <%@Page ... validateRequest="false"%>

Solve the problem:
set ValidateRequest="true" and HTMLEncode the input
For example:
title = Server.HtmlEncode(Request.QueryString["title"].ToString());

Monday, September 3, 2007

Access denied to c:\inetpub\wwwroot\xx. Failed to start monitoring file changes.

When try to run or compile an ASP.NET application, you get error message:
Access denied to 'c:\inetpub\wwwroot\xxxxxx\'. Failed to start monitoring file changes.

This is occur when try to run
  1. a copied version of ASP.NET source code (copy ASP.NET source code from one development machine to another machine)
  2. Folder permission has been reset.
Causes:

Aspnet_wp.exe process identity Or IUSR_(machinename) does not have permissions on one of the directories in the below file path:
  • Web.config files
  • Files in the Bin directory of an ASP.NET application
  • Cache dependency files
Solution:

Grant the required permissions on all of the directories in the ASP.NET process account (ASPNET) and IUSR_(machinename):
Before you start, Please make sure you have turn off Simple File Sharing if you are using windows xp.

  1. In Windows Explorer, browse to the application folder or to the virtual directory that contains the content (for example, c:\inetpub\wwwroot\xx).
  2. Right-click the folder, and then click Properties.
  3. On the Security tab, click Add.
  4. On the "Select Users or Groups" window, click on Advance
  5. Click on Find Now button, you will see List of users
  6. Select ASPNET and IUSR_(machinename) then click OK to close the"Select Users or Groups" window
  7. Allow the following permissions for the ASPNET and IUSR_(machinename) account:
    • Read & Execute
    • List Folder Contents
    • Read
  8. If you want to replace all child object permission with the same permission, Click on Advance and select check box "Replace permission entries on all child objects with entries shown here that apply to child objects" and click OK.
  9. Click OK to close the Properties dialog box and to save the changes.
  10. Restart IIS.

Sunday, September 2, 2007

bitDefender 10 Uninstall Problem

I have installed bitDefender 10 trial version. I found that it consume lot memory from my machine and not able to scan Virus 'myphotos2007.zip'. I have decided to uninstall it. Unfortunately, the process stop have way and display a blue screen. I restart the machine.



I go to Control Panal -> 'Add/Remove Program' and try to uninstall again but bitDefender 10 disappear from 'Add/Remove Program'. I thought it has been remove from my machine but i was wrong. Each time i restart or shut down my machine, above blues screen will be shown. What i try to do is install this trial version again and uninstall it. Sorry to tell, it won't work. Waste my time on doing that.

What can we do to solve it.
Go to
http://www.bitdefender.com/uninstall and download the uninstaller. Click on it to uninstaller it.

Trust me, it will take very long time for the uninstallation and after the process, it will leave your machine a mess.
  1. My wireless not working
  2. Ms Visual studio.net not working
  3. Ms SQL Server Express edition not working
I need to repair both Ms Visual studio.net and Ms SQL Server Express and also need to reset the TCP/IP setting for my wireless connection.

My advice is becareful when try to install bitDefender 10 Trial version.

Handle 'Enter' event in ASP.NET

Problem:

I have two form, search form and login form.

  1. When i keyin username and password and hit enter in Mozilla Firefox. The search form will be trigger.
  2. When i keyin a search key in search key form, validator for login form will be trigger

Form details:

  1. Search form:
    • 1 textbox
    • 1 button
  2. Login form:
    • 2 textbox
    • 2 validator
    • 1 image button

To solve the problem:

  1. Add a panel with defaultbutton for both form.

    <asp:Panel ID="pnlLogin" runat="server" defaultbutton="IbtnLogin">
    <asp:TextBox ID="username" runat="server"></asp:TextBox>
    <asp:TextBox ID="password" runat="server"></asp:TextBox>
    <asp:ImageButton ID="IbtnLogin" runat="server" ImageUrl="~/img/LoginButton.gif" OnClick="IbtnLogin_Click" />
    </asp:Panel>


  2. Set RequiredFieldValidator Enabled = false

    <asp:RequiredFieldValidator ID="vdtUsername" runat="server" ErrorMessage="Enter username" ControlToValidate="username" Enabled="False"></asp:RequiredFieldValidator>
    <asp:RequiredFieldValidator ID="vdtPassword" runat="server" ErrorMessage="Enter password" ControlToValidate="password" Enabled="False"></asp:RequiredFieldValidator>

    Enable the RequiredFieldValidator in IbtnLogin_Click
    IbtnLogin_Click(object sender, ImageClickEventArgs e)
    {
    vdtUsername.Enabled = true;
    vdtPassword.Enabled = true;
    .......................................................
    .......................................................
    .........................................
    }

problem solved!

The type 'xxx' exists in both 'c:\WINDOWS\assembly\GAC_MSIL\xx.v7.2\xx.1063_xx\xx.dll' and 'c:\WINDOWS\assembly\GAC_MSIL\xx.v7.2\xx.61_xx\xx.dll'

I got a error message "The type 'Infragistics.WebUI.Shared.Style' exists in both 'c:\WINDOWS\assembly\GAC_MSIL\Infragistics2.WebUI.Shared.v7.2\7.2.20072.1063__7dd5c3163f2cd0cb\Infragistics2.WebUI.Shared.v7.2.dll' and 'c:\WINDOWS\assembly\GAC_MSIL\Infragistics2.WebUI.Shared.v7.2\7.2.20072.61__7dd5c3163f2cd0cb\Infragistics2.WebUI.Shared.v7.2.dll'" when try to use the bug fixed version for my project, Version 7.2.20072.1063.

To solve the problem:

First, we need to determine which version that i need to use. I need to use Version 7.2.20072.1063.
Second, we need to let out application which Version we need to use by changing web.config. Locate the <assemblies> tag (which should be under <configuration><system.web> <compilation>/<compilers>/<assemblies> ) Between the <assemblies> tag, you should enter something similar to:

<add assembly="AssemblyFileName, Version=0.0.0.0, Culture=neutral, PublicKeyToken=7DD5C3163F2CD0CB" />

<compilation debug="true">
<assemblies>
<add assembly="Infragistics2.WebUI.UltraWebTab.v7.2, Version=7.2.20072.1063, Culture=neutral, PublicKeyToken=7DD5C3163F2CD0CB"/>
<add assembly="Infragistics2.WebUI.Shared.v7.2, Version=7.2.20072.1063, Culture=neutral, PublicKeyToken=7DD5C3163F2CD0CB"/>
</assemblies>

</compilation>

Problem solved!





To know (GAC) Global Assembly Cache more:

Each computer where the common language runtime is installed has a machine-wide code cache called the global assembly cache.


Go to Start -> Settings -> Control Panel -> Administrative Tools -> Microsoft .NET Framework 2.0 Configuration

Expand the nodes and locate Assembly cache


We can add new object xxxx here.

To add manually:
Run the .NET command prompt (Start -> Programs -> Microsoft VS.NET -> VS.NET Tools -> VS.NET prompt) and start the gacutil.exe tool with -i parameter (install) and the name of the control, e.g.
gacutil.exe -i "C:\xxx\xxxx.dll"

To remove manually:
To remove xxxx from GAC
Please use the following command: gacutil.exe -u xxxx

We are able to see the different version for the object that we are trying to use. To know more about GAC, please check on
MSDN.

Thursday, August 30, 2007

'System.Web.UI.UpdatePanel' does not have a public property named 'table'

I've received a error message "System.Web.UI.UpdatePanel' does not have a public property named 'table'" when trying to use AJAX.NET.

The code:

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<table>

</table>
</ContentTemplate>
</asp:UpdatePanel>

After surf for a while, i found the solution on this issue. We need to put <ContentTemplate> <table> ... </table> </ContentTemplate>

This solve the problem.