forms - ASP.NET: displaying notification on another page, after succesfully saved data to database -


i searched web haven't found real answer question..

let's have form, on addtolist.aspx, , want after hit send, direct list.aspx, message "the item added list" in message box div.

do need send list.aspx?msg=my message, or there way of doing it?

edit:

so made helper class:

   public class messagehelper : system.web.ui.masterpage     {         public void setmessage(string message)         {             session["message"] = message;         }          public string getmessage()         {             if (string.isnullorempty(session["message"]))             {                 string temp = session["message"];                 session["message"] = "";                 return temp;             }             else             {                 return "";             }         }     } 

and got error:

error   32  best overloaded method match 'string.isnullorempty(string)' has invalid arguments error   33  argument '1': cannot convert 'object' 'string' error   34  cannot implicitly convert type 'object' 'string'. explicit conversion exists (are missing cast?) 

you use query string pass data list.aspx page, careful passing text you're planning on writing out in html - you'll need protect against xss attacks.

there several other ways this. chances are, you're going have several places in application want redirect user page, display message has did on previous page (saved item, deleted item, etc.). better come more of global scheme rather one-off particular instance.

one idea use session storing message, redirect.

session("message") = "item added list." response.redirect("list.aspx") 

then, on pages (or master page, perhaps), check session("message") , if it's got something, show message user, clear variable.

if session("message") isnot nothing   response.write(ctype(session("message"), string)) 'or set label text, or show pop div, or whatever'   session("message") = nothing end if 

if use approach, recommend write helper class, , use manage messaging:

messagehelper.setmessage("item added list.") 

and

messagehelper.getmessage() 

would methods need.


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -