custom database insert method - how to use it with popups?

A

Andy B

I have the following method in C#:

public bool AddNews(DateTime Date, String subjectm, String Body) {

NewsDataSet.NewsArticlesDataTable NewsArticles = new
NewsDataSet.NewsArticlesDataTable();

NewsDataSet.NewsArticlesRow NewsArticle = NewsArticles.NewNewsArticlesRow();

NewsArticle.Date=Date;

NewsArticle.Text=Body;

NewsArticle.Title=subjectm;

NewsArticles.AddNewsArticlesRow(NewsArticle);

int RowsAffected = NewsArticlesAdapter.Update(NewsArticles);

return RowsAffected==1;

}


What I want to do, is if the method fails, display a user friendly error in
a popup dialog and if the method was successful, show a message that it
worked. How would you do this? I am trying to put it in the
FinishButton_Click event of a Wizard control.
 
M

Mark Rae [MVP]

How would you do this?

if (AddNews(...parameters go here...))
{
ClientScript.RegisterStartupScript(GetType(), "AddNews",
"alert('Success');", true);
}
else
{
ClientScript.RegisterStartupScript(GetType(), "AddNews",
"alert('Failure');", true);
}

Modify the alerts as required...
 
A

Andy B

Got it! Now one more question... What is the "AddNews" in the register
script thing for?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,142
Latest member
arinsharma
Top