Sponsored Ad

Sunday, June 6, 2010

How to Generate Random Links in ASP-C#

 

How to Generate Random Links in ASP-C#

Sometimes we need to display random links while designing a web application. Here is a solution to implement this using ASP.NET-C# coding.

This is implemented using random number generator and then checking these number and display the url on the basis of generated numbers.

How to Generate Random Links in ASP-C# Example:

<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">

<html>
<body>

<%
Random r = new Random();

double dd = r.NextDouble() ;
if (dd > 0.7)
    Response.Write("<a href='#>C# Tutorials</a>");
else if (dd > .5)
    Response.Write("<a href='#'>Software Testing Tutorials</a>");
else
    Response.Write("<a href='#>SharePoint Tutorials</a>");

%>
<p>
Example of random link generator.
</p>

</body>
</html>

No comments:

Post a Comment

Sponsored Ad

Development Updates