How to add namespace in aspx file?

<%@ Import Namespace="System.Net.Mail" %>

I'm assuming that it's in a website and that the page doesn't have code behind?

<%@ Page Language="C#" %>
<%@ Import Namespace="System.Net.Mail"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">


        protected void Page_Load(object sender, EventArgs e)
        {
            System.Net.Mail.SmtpClient client = new SmtpClient();


        }

</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>

</body>
</html>

This seems to work for me.

If it's not in a website and/or it has code behind why do you need to reference the namespace in the aspx file?

Hope this helps

Tags:

Asp.Net