winJS listview error on navigation - microsoft-metro

winJS listview error on navigation
Hi I am working on a WinJS application.I am using listview to list data.If i navigate to another page before finishing the data loading it shows error like ListView is undefined.How to resolve this issue?

Need to cancel the worker(promise) before moving to the next page. something like this:
unload: function unload()
{
if (this._loadPromise)
this._loadPromise.cancel();
},
loadListData: function load()
{
this._loadPromise = WinJS.xhr(..).then(function onxhrcomplete(req)
{
...
}).then(null, function onerror(error)
{
if (error.message == 'Canceled')
return;
// do error handling like showing message box or throw an error object
});
}

Related

Is it possible to display validation error message out side from the TextFormField

I am trying to display error message (show simple toast of error) outside from textformfield when I click submit button in login screen.
currently, error show in bottom of textformfield like this.
I am trying to display error message like this
I am trying to display error message (show simple toast of error) outside from textformfield when I click submit button in login screen. Currently error show in bottom of textformfield.i am trying to display error message in toast form.
First you need to 1 String for each field
String nameError = '';
Now you need to create validation function for this field like
void invalidName() {
nameError = "Enter name";
}
Now you need to create function where you can check all validation
bool validateInput() {
try {
if (email.isNotEmpty) {
return true;
} else {
if (nameController.text.isEmpty) { // Here check your controller value
invalidName(); // here define validation error
...
...
}
return false;
}
} catch (e) {
return false;
}
}
Now you just need to call validateInput() function in your button if it return true then call your API or something otherwise shows an error in toast message
nameError == '' ? SizedBox() : FlutterToast(nameError)

How to display a progress icon when clicking "Show more" on a CellTree?

I'm using the CellTree for the very first time and slowly getting a hang of it.
Right now I'm struggling how to display a progress icon (just like when opening a tree node) beside the "Show more" text when clicking on it.
Any ideas?
I guess it is a common problem that users are clicking on "Shore more" multiple times if they do not get any visual feedback - which leads to multiple server calls and a bunch of duplicated nodes (in my case).
Any time you send a call off to the server, you know that you are making the call. Likewise, you will get a call back into your code, whether it succeeded or failed.
For the sake of this example, I'm assuming you are using something like GWT-RPC (since the question doesn't specify):
// field to track if we're loading
private boolean isLoading = false
//...
// inside a method which needs to load data:
if (isLoading) {
return;//don't attempt to load again
}
isLoading = true;
//just before we start the call, show the loading indicator
loadingIndicator.flash();//or whatever you'd like to make it do
//then start the request
service.getMyData(param1, param2, new AsyncCallback<MyData> () {
public void onSuccess(MyData response) {
//loading was successful, so stop the loading marker
isLoading = false;
loadingIndicator.success();
//do something with the data
//...
}
public void onFailure(Throwable ex) {
//loading stopped, but it was an error, tell the user
isLoading = false;
loadingIndicator.error();
}
});

shareThis click/hover events with AJAX

I am running into an issue where I am making an AJAX call to load images into a carousel, and it is breaking the shareThis click/hover events that are associated with each image (email, twitter, and facebook).
I have read all over that by doing
stButtons.locateElements();
it should resolve the issue, but it does not. Nothing happens and the buttons remain unclickable/no hover event. I have also tried reloading the script:
var switchTo5x = true;
$.getScript('//ws.sharethis.com/button/buttons.js', function () {
stLight.options({ "publisher": "publisher-code" });
});
and that just leads to button.js throwing this error: "Uncaught TypeError: Cannot call method 'process' of null".
Any thoughts on how I can rebind the events?
I ended up figuring out a solution, although there is still an error being thrown by button.js.
Before I run getScript, I set stButtons to null and that solved my issue. Here was the end result:
if (stButtons) {
// Reset the share this buttons to null
stButtons = null;
try {
// Reload the script from scratch
var switchTo5x = true;
$.getScript('//ws.sharethis.com/button/buttons.js', function () {
stLight.options({ "publisher": "pub-id" });
});
}
catch (err) { }
}
I am still getting this error from button.js: Uncaught TypeError: Cannot read property 'messageQueueInstance' of null. But, it is working now. Will look more into this error another time.

ASP.MVC ValidationSummary on success

ValidationSummary can easly display error messages.
But how can I make it a success message I return from my action.
I am calling this action within Ajax request.
Any idea?
As you've discovered ValidationSummary is for displaying error messages. If you are using AJAX you could have your action return messages in JSON:
[HttpPost]
public ActionResult Foo()
{
// Do something
return Json(new { message = "success" });
}
And then call it:
$.post('/home/foo', { }, function(json) {
alert(json.message);
});
Ideally, I want to do something like this
ModelState.AddModelError("SUCCESS", mySuccessMessage);
I'm thinking about modifing the CSS of ValidationSummary to display the message in green color.
but I don't know where this CSS is located

Ajax Modal Popup Display Issue

On the web page, there is gridview control contains product ID's. bind to a link button.
On ItemCommand event of gridview, I fetch the product information and display in the ajax modal popup extender control. The popup is programatically show on ItemCommand of gridview and also hide programatically.
Now the problem is that, when i close popup after showing first product details and try to see next 1 by clicking on other product ID.., sometimes details are displaye dand sometimes not.
The data comes from database is fetched as well for each product.
Plz help.
I do the same but i have no such problem. So i am pasting code here that may b help full to u.
CODE:
protected void GVallusers_RowEditing(object sender, GridViewEditEventArgs e)
{
try
{
GridViewRow gvRow = ((GridView)sender).Rows[e.NewEditIndex];
populatepanel(gvRow);
ModalPopupExtender1.Show();
}
catch (Exception exc)
{
lblinfo.Text = exc.Message;
}
}
public void populatepanel(GridViewRow gvrow)
{
string userid = gvrow.Cells[0].Text;
lblSite.Text=gvrow.Cells[1].Text;
lblemail.Text = gvrow.Cells[3].Text;
}