Last post Aug 23, 2014 07:50 PM by ravininave
Aug 21, 2014 10:42 AM|ravininave|LINK
ClientScript.RegisterStartupScript(Me.GetType(), "pop", "<script>alert('Successfully Saved')</script>")
Aug 21, 2014 11:00 AM|ignatandrei|LINK
MVC controller runs on server, not on client.
From MVC you can send a string via Model ( or ViewBag) :
Model.Message = "Successfully Saved"
In the View
Aug 21, 2014 11:01 AM|MetalAsp.Net|LINK
Look at this reply: http://forums.asp.net/post/4764414.aspx
So basically you're returning some View from your controller. In that View just put the jquery "document.ready" and your alert() inside. I think...
Aug 21, 2014 12:18 PM|cnuonline|LINK
public ActionResult SomeActionName()
Aug 22, 2014 04:22 AM|Starain chen - MSFT|LINK
You also could refer to this code below:
public ActionResult Index()
Aug 23, 2014 04:05 PM|ravininave|LINK
Tried like this
Public Function Register(ByVal model As RegisterHome) As ActionResult
update logic here...
ViewBag.script = "<script>alert('hello')</script>"
'--Also tried with Return View()
Aug 23, 2014 04:32 PM|AidyF|LINK
The ViewBag won't survive a Redirect. You have to return the View. You are also storing the script in a ViewBag "script" variable but your view is reading "Scripts".
Aug 23, 2014 07:50 PM|ravininave|LINK
Yes this solved it. I was writing scripts instead of script. One more problem I'm facing here. On Controller I wrote modelstate.clear() to clear all the inputbox. it clears the inputbox after submit but if again I press F5 then it again saves the data.
How to avoid this.? But if I write return redirect("viewname") then it works but doesn't shows alert. How to solve this?