jquery - How do I show error messages back to an ASP.NET MVC page? -


Note that StackOverflow displays some good status bar messages based on your activity? (The orange bar on the top page) I hope to do this, but I'm not sure how.

Now I know the UI to display verification errors by using ASP.NET MVC 1.0 ... it is not very difficult. But if I want to show a status bar (not sure what they are called) and I guess they are done with jQuery ... how do you do this.

Also, I also want

for example

  Public Action Authorized Worldwriters (string aliases) {// Authorize, etc. ... etc) We have the TwitterOath Access Token // (i.e. we are back from twitter oak) // Then go back to index action, but a status bar / / 'message' / 'thank you / get / etc' Display. . Redirect return action ("index", new [] {alias}); }  

I'm not sure how I should send the message back to that verb and how to display that message with one of the things in the status bar.

Cheers!

Many ways:

  1. In tempdata ["static"] Keep it and choose it from there in your action or view. Drawbacks: If the user has not clicked on it and reloaded the page, then it has not been displayed again.
  2. Put it in session. When you click the user on the status link, you will only remove it from the session.

You can use TempData / session directly, or you can do the BaseController with StatusMsg property and related content, or you can substitute the baseview (all of your actions see the base class of the model ) This status message is the property.

jQuery for the status bar, you can easily choose from a Google, for example, although if you want to place it at the top, then it is very easy, just a few css / jquery Pairs: Set the full, 100% width, possibly ambiguity at position 0: 0, then when you receive msg,

  & lt; Script & gt; & Lt;% If (model status message! = Zero)%> $ (Function () {$ ("# statusbar"). FadeIn ();}); & Lt;%}% & gt; & Lt; / Script & gt;  

Okay here's more. You have ID = "msg" and

  #msg {text-align: center; Is div with; Status: Completed; Line-height: 2 AM; Left: 0 pixels; Top: 0 pixels; Width: 100%; display none; Opacity: 0.7; Background color: # aaf; Border bottom: 1px solid black; }  

You can fix the element at the top so that it does not scroll using the page. Now, whenever you have a status message, the session ["status"] = "mamsage" Alternatively, you put a message in BaseController.OnActionArother Override and session (if this app is wide) .

Then in your opinion,

  " + text + ""); } $ (Function () {if (session ["status"] = null) {%> var status = '& lt;% = session ["status"]% & gt;'; shoestatus (Position); & lt;%; sessions. Remove ("status");}%>;);); & Lt; / Script & gt;  

You can escape the session. Remove the "status" from doing so in the base on an action exping:

  {if (session ["status"]! = Null) {see data ["status"] = session ["status" ]; Session.Remove ("status"); }}  

and then see the context instead of the session in the view.

Now, of course, there can be anything else to do this, and the code above is my head, unwanted ... but if it is not enough to talk in 5 minutes then you Only hope that someone will take time to provide complete work solution ... and will not take money for it -)


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -