how to display message like "Record Already Exist" or "Error Happen" in Alertbox - asp.net-mvc

I am using kendo ui grid view and also use inline editing in NopCommerce.
now i want to check exist(for only one field) or not and if exist then not insert record in table this thing working fine.
but no any message display like "Record Already Exist" or "Error Happen".
and i see code of language resource string gird view and its working fine but i am not understand how to fire alert and display message as well.
please help me

There was a bug in nopCommerce 3.30 which did not properly display this error (fixed in the upcoming version 3.40).
You can return an error text the following way for grids:
return Json(new DataSourceResult() { Errors = "Your error text here" });

Related

How to remove apex.widget.waitPopup() when ui dialog opens

I need to remove waitPopup() when "value required" error is displayed. (Correct errors before saving.)
Do you have any suggestions?
I have DA Before Page Submit:
$('body').append('<div class="apex_wait_overlay"/>');
vWait = apex.widget.waitPopup();
I already have remove when validation error appears. (jQuery Selector -> #APEX_ERROR_MESSAGE)
try{
vWait.remove();
$('body').children('div.apex_wait_overlay').remove();
}
catch(e){}
It would be nice if it was possible on ui dialog too.
waitPopup blocks clicking on dialog
Thanks

How to get text from alertbox in spectron-mocha-webdiverio

I am testing my electron app using spectron.
I am trying to get text from alertbox but getting an error.
I want to get the text from alert and if that is expected then accept it.
Test :
it('Check alert message', function() {
return this.app.client
.waitForExist('#associates', 20000).should.eventually.equal(true)
.click('#pq-associates')
.click('#submit-selection')
.alertText().should.eventually.equal("You have to select any one")
.should.eventually.exist
});
I am getting the following error
no alert open
Error: An attempt was made to operate on a modal dialog when one was not open.
But I can see the alert.
As discussed with the WebDriverio community it is difficult to handle the default alert() function. They suggested to implement my own alert() like function. So using https://github.com/limonte/sweetalert2 I implemented my own alert and the test is working fine.
Community discussion : https://gitter.im/webdriverio/webdriverio/archives/2017/10/04
Spectron issue : https://github.com/electron/spectron/issues/23

MVC Custom Validation against List

I have a List Which i am checking within my Custom Validation attribute. List Renders like this on my VIEW
<input type="check" value="Bath">
<input type="check" value="Food">
and my Custom Validator is...
public class MyAttribute: ValidationAttribute
{
// some logic and then
// Get Data from some webservice
// Make sure CERTAIN checkboxes are selected
// If Bath was NOT checked then
return new ValidationResult("Bath is Required")
// If Food was NOT checked then
return new ValidationResult("Food is Required")
}
Now this works fine & I can show the error message "Some Error" on my view, However my issue is I want to show the RED ERROR BOX around the checkbox which was REQUIRED to check. Currently i am just showing a Error message string on my VIEW. It would be nice for user to see what was REQUIRED.
You can pass a style attribute as the 3rd Argument to the ValidationMessageFor method in razor view as such:
#Html.ValidationMessageFor(m=>m.StudentName, "", new { #style="color:red" })
You can also run your application trigger the validation message, in chrome, right click the validation message and inspect element, go to the debugger window and trace the class associated with the validation error message.
Go to site.css and overwrite the default validation-error message class as shown below:
span.field-validation-error {
background-color: #ffeeee;
outline: 1px solid #ff0000;
}
Hope this will help.

WatiN: Print Dialog

I have a screen that pops up on load with a print dialog using javascript.
I've just started using WatiN to test my application. This screen is the last step of the test.
What happens is sometimes WatiN closes IE before the dialog appears, sometimes it doesn't and the window hangs around. I have ie.Close() in the test TearDown but it still gets left open if the print dialog is showing.
What I'm trying to avoid is having the orphaned IE window. I want it to close all the time.
I looked up DialogHandlers and wrote this:
var printDialogHandler = new PrintDialogHandler(PrintDialogHandler.ButtonsEnum.Cancel);
ie.DialogWatcher.Add(printDialogHandler);
And placed it before the button click that links to the page, but nothing changed.
The examples I saw had code that would do something like:
someDialogHandler.WaitUntilExists() // I might have this function name wrong...
But PrintDialogHandler has no much member.
I initially wasn't trying to test that this dialog comes up (just that the page loads and checking some values on the page) but I guess it would be more complete to wait and test for the existence of the print dialog.
Not exactly sure about your situation, but we had a problem with a popup window that also displayed a print dialog box when loaded. Our main problem was that we forgot to create a new IE instance and attach it to the popup. Here is the working code:
btnCoverSheetPrint.Click(); //Clicking this button will open a new window and a print dialog
IE iePopup = IE.AttachToIE(Find.ByUrl(new Regex(".+_CoverPage.aspx"))); //Match url ending in "_CoverPage.aspx"
WatiN.Core.DialogHandlers.PrintDialogHandler pdhPopup = new WatiN.Core.DialogHandlers.PrintDialogHandler(WatiN.Core.DialogHandlers.PrintDialogHandler.ButtonsEnum.Cancel);
using (new WatiN.Core.DialogHandlers.UseDialogOnce(iePopup.DialogWatcher, pdhPopup)) //This will use the DialogHandler once and then remove it from the DialogWatcher
{
//At this point the popup window will be open, and the print dialog will be canceled
//Use the iePopup object to manage the new window in here.
}
iePopup.Close(); // Close the popup once we are done.
This worked for me:
private void Print_N_Email(Browser ie)
{
//Print and handle dialog.
ie.Div(Find.ById("ContentMenuLeft")).Link(Find.ByText(new Regex("Print.*"))).Click();//orig
Browser ie2 = Browser.AttachTo(typeof(IE), Find.ByUrl(new Regex(".*Print.*")));
System.Threading.Thread.Sleep(1000);
PrintDialogHandler pdh = new PrintDialogHandler(PrintDialogHandler.ButtonsEnum.Cancel);
new UseDialogOnce(ie2.DialogWatcher, pdh);
ie2.Close();
}
You still might want to check your browser AutoClose property ie.AutoClose

Flash/Actionscript2 - Can't get comboBox "change" event to fire

I'm trying to use the combobox component for Flash. I can't get the change event to fire. My code is pretty much straight of of the adobe site (link below). The box gets populated but changing the value produces no trace output. What am I doing wrong?
http://livedocs.adobe.com/flash/mx2004/main_7_2/wwhelp/wwhimpl/js/html/wwhelp.htm?href=00002149.html#3138459
myCombo.addItem("hi1", "hi5");
myCombo.addItem("h2", "hi6");
myCombo.addItem("hi3", "hi7");
myCombo.addItem("h4", "hi8");
var form = new Object();
form.change = function(eventObj){
trace("Value changed to " + eventObj.target.value);
}
myCombo.addEventListener("change", form);
I pasted your code into an AS2 project and it worked as expected for me. No other output? Try adding a trace before and after the addEventListener to make sure it's getting called. Try using a name other than form for your object. Try running it in debug and set a breakpoint in the change function.

Resources