AI OnAI Off
Hi,
I have done the following coding:
public override void ApplyEditChanges()
{
try
{
ValidateSignPost()
base.SetValue(strSelectedValue);
}
catch
{
}
}
public void ValidateSignPost()
{
List<ListItem> LstTest = new List<ListItem>();
if (CurrentPage["HideSignPost"] != null &&
(CurrentPage["SignPost1"] != null))
{
LstTest = lbSignPost.Items.OfType<ListItem>().Where(a => a.Selected).ToList();
if (LstTest.Any(li => li.Value == (CurrentPage["SignPost1"].ToString())))
{
AlertAndClose();
}
}
}
protected void AlertAndClose()
{
this.Page.Response.Write(@"<script language='javascript'>alert('Sign Post and Hide Sign Post Values should not be the same.');</script>");
}
With this code when I click on Save and Publish, I'm able to see an alert message but after closing the alert box I'm seeing that the page is published.
Is there any way that we can stop loading the page and to stay back on the Edit panel itself?
Thanks.
Instead of returning script fragment try to add validation error to the collection:
protected void AlertAndClose()
{
base.AddErrorValidator("Sign Post and Hide Sign Post Values should not be the same.");
}
I’m using two Custom properties in a page.
One is a dropdownlist control and the other is a listbox.
I want to do a validation like If the Item selected from dropdown is matching with any selected item of the List box, then I need to show a message in the screen.
Please let us know your ideas.
Thanks.