STEP 1: Create a VisualWebPart like NewsAndArticles
STEP 2: Write a coding in NewsAndArticlesUserControl.ascx.cs
STEP 3:
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using VCSB.INTRANET.BLL;
namespace VCSB01.INTRANET.NewsAndArticles
{
public partial class NewsAndArticlesUserControl : BasePage
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (IsSuperAdmin || IsAdmin || IsManager )
{
imgbtnAdd.Visible = true;
}
else
{
imgbtnAdd.Visible = false;
}
NewsAndArticlesdata();
}
}
public void NewsAndArticlesdata()
{
NewsAndArticlesBL newsandarticle = new NewsAndArticlesBL();
grddataNewsAndArticle.DataSource = newsandarticle.GetNewsAndArticleData();
grddataNewsAndArticle.DataBind();
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(txtTitle.Text) && !string.IsNullOrEmpty(txtDescription.Text) && !string.IsNullOrEmpty(txtArticleDate.Text))
{
NewsAndArticlesBL newsAndArticlesBL=new NewsAndArticlesBL(txtTitle.Text, txtDescription.Text,Convert.ToDateTime(txtArticleDate.Text), fldNewsImage);
if (newsAndArticlesBL.insert())
{
NewsAndArticlesdata();
clear();
//insert success
}
else
{
//fail
}
}
clear();
}
public void clear()
{
txtTitle.Text = string.Empty;
txtDescription.Text = string.Empty;
txtArticleDate.Text=string.Empty;
}
}
}
STEP 2: Write a coding in NewsAndArticlesUserControl.ascx.cs
STEP 3:
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using VCSB.INTRANET.BLL;
namespace VCSB01.INTRANET.NewsAndArticles
{
public partial class NewsAndArticlesUserControl : BasePage
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (IsSuperAdmin || IsAdmin || IsManager )
{
imgbtnAdd.Visible = true;
}
else
{
imgbtnAdd.Visible = false;
}
NewsAndArticlesdata();
}
}
public void NewsAndArticlesdata()
{
NewsAndArticlesBL newsandarticle = new NewsAndArticlesBL();
grddataNewsAndArticle.DataSource = newsandarticle.GetNewsAndArticleData();
grddataNewsAndArticle.DataBind();
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(txtTitle.Text) && !string.IsNullOrEmpty(txtDescription.Text) && !string.IsNullOrEmpty(txtArticleDate.Text))
{
NewsAndArticlesBL newsAndArticlesBL=new NewsAndArticlesBL(txtTitle.Text, txtDescription.Text,Convert.ToDateTime(txtArticleDate.Text), fldNewsImage);
if (newsAndArticlesBL.insert())
{
NewsAndArticlesdata();
clear();
//insert success
}
else
{
//fail
}
}
clear();
}
public void clear()
{
txtTitle.Text = string.Empty;
txtDescription.Text = string.Empty;
txtArticleDate.Text=string.Empty;
}
}
}
No comments:
Post a Comment