I want to store the contents of Comment in ViewState when user is not login. After Login i want to redirect him on that page where he has filled comments and i want show the contents in comments filled by him.For this i am storing the comments'content in ViewState using AjaxMethod and JavaScript but it is not working for me. How i will do it,Please suggest me. My code is given below:
[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.ReadWrite)]
public string InsertComments(string session,string comment)
{
if (session != "0")
{
try
{
UserDTO objInsert = new UserDTO();
UserBAL objInsertComments = new UserBAL();
objInsert.EmailId = Session["usr"].ToString();
objInsert.URL = strURL;
objInsert.Comments = comment;
string c = objInsertComments.Insert_UsersComment(objInsert);
int i = Int32.Parse(c);
return "success";
}
catch (Exception ex)
{
return "Sorry! Your request can not be updated at this moment. \n\n Error Details:\n" + ex.Message + "\n\n We suggest you to try again in few moments. If this happens very often, please do contact admin.";
}
}
else
{
ViewState["GIComment"] =comment;
return "Error.";
}
}
On Page Load i am writing following code:
if (ViewState["GIComment"] != null)
txtComment.Text = ViewState["GIComment"].ToString();
else
txtComment.Text ="";