custom database insert method - how to use it with popups?
custom database insert method - how to use it with popups?
am 01.01.2008 19:38:27 von 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.
Re: custom database insert method - how to use it with popups?
am 01.01.2008 19:48:19 von mark
"Andy B" wrote in message
news:e1st5VKTIHA.3516@TK2MSFTNGP02.phx.gbl...
> 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...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Re: custom database insert method - how to use it with popups?
am 01.01.2008 20:03:06 von Andy B
Got it! Now one more question... What is the "AddNews" in the register
script thing for?
"Mark Rae [MVP]" wrote in message
news:OCCxTbKTIHA.5264@TK2MSFTNGP02.phx.gbl...
> "Andy B" wrote in message
> news:e1st5VKTIHA.3516@TK2MSFTNGP02.phx.gbl...
>
>> 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...
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net
Re: custom database insert method - how to use it with popups?
am 01.01.2008 20:24:06 von mark
"Andy B" wrote in message
news:ugXXrjKTIHA.1164@TK2MSFTNGP02.phx.gbl...
> Got it! Now one more question... What is the "AddNews" in the register
> script thing for?
http://msdn2.microsoft.com/en-us/library/z9h4dk8y.aspx
--
Mark Rae
ASP.NET MVP
http://www.markrae.net