Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
7
Reply
How to Read Tempdata, Viewbag to external JS file using ajax
ashok kumar
Jun 26 2015 3:43 AM
1.7k
Reply
How to Read Tempdata, Viewbag in external JS file using ajax jquery method
I have logon controller with method
public ActionResult Index()
{
TempData["Ex"] = "True";
return View();
}
i called a request by button's click event and click event code is in external js file as given
var data = $('form').serialize();
$.ajax({
url: "../RP/GetDetails",
// RP is another controller
dataType: 'html',
t ype: "GET",
data: data,
contentType: "application/html; charset=utf-8",
success: function (data)
{
if (
'@Html.Raw(TempData["Ex"])'
== 'True')
// Need to access tempdata value here
{
/ / Perform some action
}
else
{
// Else perform some other action
}
},
error: function (error)
{
alert("Please Check Model..!!");
}
});
In this case, Method of report controller is called on button click event but if session is expire then automatically login controller is called and tempdata
value is set based on that tempdata value in external js file, action will be prosessing but i am unable to get
TempData["Ex"]
js file.
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
7
)
Next Recommended Forum
Validation for Max & Min date for Textbox ?
How to generate employee ID in c# asp.net