28
Feb
2019

Add webpage in a website using C#, asp.net in visual studio.

Add webpage in a website using C#, asp.net in visual studio.. Add webpage in a website using asp.net and C# language using visual studio tool.

in this section you will learn that how can we add a webpage in a website using GUI or graphical user interface of visual.

1. Asp.net Designing side file coding for adding a new webpage to a website. Complete Coding

Asp.net Coding side file for adding a new webpage to a website. Complete Coding

Add webpage in a website using C#, asp.net in visual studio.
How to add new webpage

Coding Side for asp.net

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;

public partial class admin_addNewpages : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DateTime rightNow = DateTime.Now;
txt_date.Text = String.Format(“{0:d}”, rightNow);
}
protected void btn_insert_Click(object sender, EventArgs e)
{
String str = System.Configuration. ConfigurationManager. ConnectionStrings [“con_str”]. ConnectionString;
SqlConnection con = new SqlConnection(str);
SqlCommand cmd = new SqlCommand();
con.Open();

cmd.Connection = con;
cmd.CommandText = “insert into webpages ( page_Title, page_descr, page_Detail, page_Loc, page_Logo, page_Banner, page_date) values (‘” + txt_pageTitle.Text + “‘ , ‘” + txt_pDescr.Text + “‘ , ‘” + txt_pDetail.Text + “‘ , ‘” + drp_loc.SelectedValue + “‘ ,'” + FileUpload_pLogo.FileName + “‘ , ‘” + FileUpload_pBanner.FileName + “‘, ‘”+txt_date.Text+”‘) “;

cmd.ExecuteNonQuery();
int i = cmd.ExecuteNonQuery();
if (i == 1)
{
Response.Write(“Rcord inserted Successfully”);
Response.Redirect(“webPages.aspx”);
}
else
{
Response.Write(“Rcord Not inserted plz Try Again”);
// Response.Redirect (“webPages.aspx.aspx”);
}
}
}

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *