ASP.NET FAQs

What platforms does ASP.NET run on?
Currently, it is supported on Windows 2000/2003 and Windows XP. ASP.NET integrates with Internet Information Server (IIS) and thus requires that IIS be installed.

Which languages can i use to write code in ASP.NET pages?
VB.NET, C# and JScript.Net

Can a single .ASPX contain two web forms?
No.

How do i send a mail from ASP.NET page?
The following snippet shows how to do it.

<%@ import namespace="system.web.mail"%>

<%
dim message as new MailMessage()

message.From = "srikanthpragada@yahoo.com"
message.To = "you@somedomain.com"
message.Subject = "Batch Schedule"
message.Body = "Some body"
SmtpMail.SmtpServer = "srikanthtechnologies.com"
SmtpMail.Send (message)

%>

Why some Web service classes derive from System.Web.WebServices; others do not?
If you want to use intrensic objects in your Web service then derive Webservice class from WebService class

How do I create an ASPX page that periodically refreshes itself?
Most browsers recognize the following META tag as a signal to automatically refresh the page every nn seconds:
<meta http-equiv="Refresh" content="nn">
nn is number of seconds.

Alternatively you can use Response.AppendHeader to add header "Refresh" with appropriate interval in seconds. The following page will be refreshed for every 10 seconds.

response.appendheader("refresh",10)

How can an ASP.NET application determine whether cookies are enabled in a browser?
Determining whether cookies are enabled requires a round trip to the browser and back. The basic strategy is to return a cookie in an HTTP response and redirect to a page that checks for the cookie.

<%
    ' Page1.aspx
    dim c as new HttpCookie("c1", "v1")
    Response.Cookies.Add (cookie)
    Response.Redirect ("page2.aspx")

%>


<%
   ' page2.aspx

   dim c as HttpCookie

   c = Request.Cookies("c1")
   if c is nothing or  c.value <> "v1" then
          Response.Write ("Cookies are not enabled")
   else
          Response.Write ("Cookies are enabled")
%>

How can ASP.NET application transmit data from one page to another?
One way to transfer data from page to page is to use querystring as follows:
<%
  ' Page1.aspx
  dim st as string = "somevalue"
  response.redirect("page2.aspx?value=" & st)

%>

<%
   ''page2.aspx

   dim st as string
   st = request.querystring("value")

%>

Another ways is to store data in SESSION variable. The following code shows it:
<%
  '' Page1.aspx
  dim st as string = "somevalue"
  session("value") = st
  response.redirect("page2.aspx")

%>

<%
   ''page2.aspx

   dim st as string
   st = session("value")

%>




Is it possible to create a DataGrid that uses scrolling rather than paging?
With a little help from a <div> tag, yes. The following ASPX file displays scrolling table:
<script runat=server>

  bind data to grid

</script>

<html>
  <body>
    <form runat="server">
      <div style="height: 256px; overflow: auto">
        <asp:DataGrid ID="MyDataGrid" Width="100%" RunAt="server" />
      </div>
    </form>
  </body>
</html>