Completing an In-Text Advertising System under an ASP.NET 3.5 Environment - Manage the Ad Contents
(Page 5 of 5 )
If you click the "Go to manage the AD contents" hyperlink at the top of the "Admin1.aspx" page, you will be navigated to the "Admin2.aspx" page, where you can manage the specified keyword-related ad contents—browse, add, and delete some items. Figure 4 indicates the running time snapshot of the "Admin2.aspx" page.
Figure 4—Admin2.aspx: managing the ad contents
_html_m40113b84.png)
As you’ve seen from the figure, there are one-to-many relationships between the ad keywords and the contents. For example, the CSS keyword is bound to two items of content: "google" and "search engine." The basic coding logic of this page quite resembles that of the "‘Admin1.aspx" page. Here we only give the server-side code related to the "Admin2.aspx" page:
public partial class admin2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//not logged, then force to login first
if (Session["admin"]==null||Session["admin"].ToString() != "true") Response.Redirect("login.aspx");
if (!IsPostBack)
{
myDataBind();//data binding
}
}
//paging
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
myDataBind();
}
//delete
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "del")
{
string id = e.CommandArgument.ToString();
try
{
Sql s = new Sql();
s.ExecuteSql("delete from ad where id=" + id);//delete
myDataBind();
}
catch
{ }
}
}
//datasource binding
private void myDataBind()
{
Sql s = new Sql();
string str = "select ad.*,keyarray.name from ad inner join keyarray on ad.keyid=keyarray.id order by ad.id desc";
DataSet ds = s.getMyDataSet(str);//add the ad contents
GridView1.DataSource = ds;
GridView1.DataBind();
}
//add the ad content
protected void Button1_Click(object sender, EventArgs e)
{
int result;
Sql s = new Sql();
//add the ad content
result =s.ExecuteSql("insert into ad(keyid,description,url) values('"+ DropDownList1.SelectedValue +"','"+ TextBox2.Text+"','"+ TextBox1.Text+"')");
string msg = "alert('Operation failed!')";
if (result == 1)//if peration succeeded,then prompt
{
TextBox2.Text = TextBox1.Text = "";
msg = "alert('Operation succeeded!')";
myDataBind();
}
//the client side prompt
ClientScript.RegisterStartupScript(this.GetType(), "asdf", msg, true);
}
}
In the above code, we’ve also provided enough comments. So we won’t waste any more words on details.
Summary
In-text advertising is a new form of advertising through the Internet. In this series of articles, we have constructed a simple in-text ad system. Despite its simplicity, we’ve given you the basic idea and the core routine involved in developing a real-life in-text ad application. And of course, due to its simplicity, it has numerous points that need to be perfected. For example, in practical systems, you’d better add the following supports:
1. Make the user center for the advertisers facilitate the placing of ads as well as allow them to view their own advertising effects.
2. Provide support for preventing practical fraud and spiteful clicking so as to insure the correctness of the system.
3. Add support for the on-line payment so as to facilitate the advertisers in adding ad rates for their ads online, and enable the website owners to obtain their own ad income in the online mode.
4. Categorize the websites and ad keywords. For example, you can have some specified category-related websites which can only exhibit ad keywords relating to this category. The final aim is to better the effect of the advertisement.
-DOWNLOAD SOURCE-
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |