silverlight 4 RIA update item in domaindatasource only updates after refresh - silverlight-4.0

I have created a silverlight app and have a listbox that is populated using a domaindatasource. I have created a button that takes the selected list item and updates a field (in my case its called IsDeleted)
my domain service looks like this
public IQueryable<Employee> GetEmployees(int storeID)
{
return this.ObjectContext.Employees.Where(e=>(e.StoreID==storeID)&&(e.IsDeleted==false));
}
In my button event I am doing this
EmployeeRecord.IsDeleted = true;
dsEmployee.SubmitChanges();
The database is been updated as expected until the application is reloaded or I F5 than I don't see the update.
What else should I be doing to see the update straight away?

You need to reload your domain context. Call the following:
myDomainDataSource.SubmitChanges((submitArgs) =>
{
if (submitArgs.IsComplete)
{
myDomainDataSource.Load<MyType>(myDomainDataSource.MyQuery(filterTextBox.Text), System.ServiceModel.DomainServices.Client.LoadBehavior.RefreshCurrent, true);
if (myDataSource.CanLoad)
myDataSource.Load();
}
else if (submitArgs.HasError)
{
throw submitArgs.Error;
}
}, null);

Related

MVC 4 website back press return the same form with old values

I am new in MVC 4 web development and i am creating a control panel. I have developed a Add user page and submit information in database successfully.
But after submit when i press back button it will show previous form.
i am using redirection the page to same page after submit form.
here is the code to redirect
public ActionResult AdminPanel(RegisterUserModel user)
{
if (ModelState.IsValid) // Check the model state for any validation errors
{
if (user.AddUserToDB(user.username, user.password, user.fullName,user.contactNo,user.COAId)) // Calls the Login class checkUser() for existence of the user in the database.
{
TempData["SuccessMessage"] = "User Added Sucessfully!";
ModelState.Clear();
return Redirect("AdminPanel");
}
else
{
ViewBag.SuccessMessage = "User Not Added";
return View();
}
}
SelectList clientsList = GetClinetList();
ViewBag.clientsList = clientsList;
return View(); // Return the same view with validation errors.
}
I have tried many examples but issue not resolved yet so kindly give my suggesstions
If you don't want the user to be able to see the previous content when clicking back, then you must indicate that content should not be cached by the browser and must revalidate with the origin server
A summary of this behaviour is here - http://blog.55minutes.com/2011/10/how-to-defeat-the-browser-back-button-cache/
You could create a nocache attribute, like this one - https://stackoverflow.com/a/10011896/1538039, and apply it to your controller methods.

two wizards loading at the same time in swt

I have two wizards ProjectWizard and ModifyEditWizard. I am adding both in the same page like below
projectPage = new ProjectPage(objSelected);
addPage(projectPage);
modifyeditpage=new ModifyEditPage(objSelected);
addPage(modifyeditpage);
also using :
public IWizardPage getNextPage(IWizardPage currentPage) {
currentPage.setPreviousPage(projectPage);
if(currentPage!=null && currentPage instanceof ProjectPage ){
modifyeditpage.setProjectIdValue(projectPage.getProjectIdValue());
return modifyeditpage;
}
return null;
}
The Problem I'm facing is the two page gets loaded at the same time when this wizard. I want to take input from first wizard and according to that populate data in next wizard.

devexpress customer popup edit from validation doesn't work while adding

I am using the Dev-express in my project for data that should be shown in a grid.
While i am using popup mode the validation is not working its directly modelstate.valid is getting true, but the values are null and/or not valid.
How can I solve this?
if (ModelState.IsValid)
{
try
{
//code is here the control is coming inside if ...
}
}

MVC Grid Delete Record Action Performing Full Page Load, How to stop this?

I have an mvc grid.
Next to each record is a delete button.
This delete button corresponds to an action DeleteRecord. The action deletes this record and performs a RedirectToAction("MyGrid");.
This works pretty well but what is annoying is the fact that my redirectaction causes the entire page to reload. This is something I am trying to stay away from, but can't seem to figure out a way around this.
I start out like this.
/MyApp/MyGrid => click delete
/MyApp/DeleteRecord => redirect
/MyApp/MyGrid => full reload of page
Maybe this isn't possible but I tried doing this by using overriden actions and actions with different action names, but this didn't solve my full reload. I am new to MVC so maybe this isn't even possible. I was thinking maybe if I just did an ajax.post on the clientside that I could get away from this but the more I think about it the more likely that it just will end up in the same action performing the same redirect.
Any ideas on how to get around this situation?
I actually ended up just tying into the callback function of the grid and the inline delete of the grid function and it worked. Although, extremely hackish, it stops the full post back by hoping into the inline grid delete code. Although, you can't count on the callback javascript routines to run in order as that is just how javascript works right. ; o
s.SettingsEditing.DeleteRowRouteValues = new { Controller = "Home", Action = "DeleteRecordGrid" };
s.ClientSideEvents.EndCallback = "function(s,e) { OnEndCallback(s, e, 'delete') }";
<script type="text/javascript">
function deleteWithoutPostback(eVisibleIndex) {
var okToDelete = confirm("Do you really want to delete this record?");
if (okToDelete == true) {
myGrid.DeleteRow(eVisibleIndex);
myGrid.ClearFilter();
} else {
return;
}
}
function OnEndCallback(s, e, callType) {
if (typeof callType == 'undefined') {
if (callType == 'delete') {
myGrid.Refresh();
}
}
}
</script>

Generating a modal jQuery partial view with MVC4 does not work

I like the way MVC4 manage the new logon screen: it is possible to have a modal dialog showed.
I tried to reproduce the same behavior in the same solution for another view. But it doesn't work because Request.QueryString["content"] is null. I don't know why. In fact, there is an action method called ContextDependentView (generated by the MVC template) where the trick occurred. Here it is:
private ActionResult ContextDependentView()
{
string actionName = ControllerContext.RouteData.GetRequiredString("action");
if (Request.QueryString["content"] != null)
{
ViewBag.FormAction = "Json" + actionName;
return PartialView();
}
else
{
ViewBag.FormAction = actionName;
return View();
}
}
If the value of Request.QueryString["content"] is not null then we display a partial view (modal jQuery) otherwise it is a classic view.
Can someone help me understand why this is not working?
PS: another thread already exists but without any solution.
The login and register links are bound to a click handler in AjaxLogin.js which then adds content=1 in loadAndShowDialog