function ValidateUpDetails(source, arguments) {
arguments.IsValid = getRadUpload(
'<%# upDetails.ClientID %>').validateExtensions();
}
and called this on ClientValidationFunction of custom validator. Now I have a requirement in which I would like to click on a button and that button takes text from email text box and checks the database for records containing that email address, Even if user does not fill other textboxes and only fill email textbox and click on check button it should bring the results via Ajax call and populate the Grid. I have designed all the functionality and it also works but the problem is on Ajax call the validators also work which I don't want and a javascript error also pop up saying 'null' is null or not an object and this error is because of the custom validation function shown above.
I am using AjaxManager and configured it to work on button click and selected the grid and sqldatasource as items for updating, in sqldatasource I decalared a variable @email for which I defined my email textbox as source control.
Is there anyway to make an ajax call without activating validators ? I hope I explained it properly, I am fairly new with ASP.NET and RadControls, I am/was a PHP programmer so all this stuff is new for me.
Thanks.
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<telerik:RadScriptBlock runat="server" ID="RadScriptBlock1">
<script type="text/javascript">
function openForm() {
var dock = $find("<%= RadDock1.ClientID %>");
// Center the RadDock on the screen
var viewPort = $telerik.getViewPortSize();
var xPos = Math.round((viewPort.width - parseInt(dock.get_width())) / 2);
var yPos = Math.round((viewPort.height - parseInt(dock.get_height())) / 2);
$telerik.setLocation(dock.get_element(), { x: xPos, y: yPos });
dock.set_closed(false);
Sys.Application.remove_load(openForm);
}
function hideForm() {
var dock = $find("<%= RadDock1.ClientID %>");
dock.set_closed(true);
return true;
}
function dockMoved(sender, args) {
//Return RadDock to his original HTML parent so it gets updated via ajax
$get("<%= DockPanel.ClientID %>").appendChild(sender.get_element());
}
</script>
</telerik:RadScriptBlock>
<asp:UpdatePanel runat="server" ID="UpdatePanel1" ChildrenAsTriggers="true" >
<ContentTemplate>
<asp:Panel runat="server" ID="DockPanel">
<telerik:RadDock runat="server" ID="RadDock1" Skin="Windows7" Width="800px" Height="600px" Closed="true"
Style="z-index: 2000;" Title="Appointment" OnClientDockPositionChanged="dockMoved" >
<ContentTemplate>
<asp:CheckBox ID="chkAllDay" runat="server" Checked = "true" AutoPostBack="true" Text="All Day" />
</ContentTemplate>
</telerik:RadDock>
</asp:Panel>
<telerik:RadScheduler ID="RadScheduler1" runat="server" Skin="Windows7" DataEndField="End" DataKeyField="ID"
DataRecurrenceField="RecurrenceRule" DataRecurrenceParentKeyField="RecurrenceParentID"
DataDescriptionField="Description"
DataSourceID="SqlDataSource1" DataStartField="Start" DataSubjectField="Subject"
HoursPanelTimeFormat="htt" OverflowBehavior="Expand" ValidationGroup="RadScheduler1"
OnFormCreating="RadScheduler1_FormCreating"
StartEditingInAdvancedForm="false"
StartInsertingInAdvancedForm="false"
AppointmentContextMenuSettings-EnableDefault="true"
TimeSlotContextMenuSettings-EnableDefault="true" SelectedView="MonthView">
</telerik:RadScheduler>
</ContentTemplate>
</asp:UpdatePanel>
AutoPostBackOnFilter = true;
CurrentFilterFunction = Telerik.Web.UI.GridKnownFunction.Contains;
ShowFilterIcon = false;
HeaderStyle.Width = _width;
ItemStyle.Width = _width;
ItemStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Right;
HeaderTemplate = new MyHeaderTemplate(_type, DataField, _width.Value - CommonParameters.GridFilterWidthDistances, LabelText);
ItemTemplate = new MyTemplateText(new GridTemplateColumnParameter()
.SetColumnType(CommonParameters.RadGridTemplateColumnType.ItemTemplate)
.SetDataField(DataField)
.SetDataFieldItem(DataFieldItem)
.SetWidth(_width.Value - CommonParameters.GridFilterWidthDistances)
.SetReadOnlyOn(_readOnlyOn)
);
EditItemTemplate = new MyTemplateText(new GridTemplateColumnParameter()
.SetColumnType(CommonParameters.RadGridTemplateColumnType.EditItemTemplate)
.SetDataField(DataField)
.SetDataFieldItem(DataFieldItem)
.SetWidth(_width.Value - CommonParameters.GridFilterWidthDistances)
.SetReadOnlyOn(_readOnlyOn)
.SetRequired(_required)
.SetCodice(_codice)
.SetMaxLength(_maxLength)
.SetLabelText(LabelText)
);
private class MyTemplateText : IBindableTemplate
{
private TextBox _txb;
private Label _lbl;
private GridTemplateColumnParameter _gtcp;
public MyTemplateText(GridTemplateColumnParameter pGtcp)
{ // Parametert to create label ant text box of the template column
_gtcp = pGtcp;
}
#region IBindableTemplate Members
public System.Collections.Specialized.IOrderedDictionary ExtractValues(System.Web.UI.Control pContainer)
{
OrderedDictionary data = new OrderedDictionary();
switch (_gtcp.ColumnType)
{
case CommonParameters.RadGridTemplateColumnType.ItemTemplate:
data.Add(_gtcp.DataField, _lbl.Text);
break;
case CommonParameters.RadGridTemplateColumnType.EditItemTemplate: data.Add(_gtcp.DataField, _txb.Text); break;
}
return data;
}
#endregion
#region ITemplate Members
public void InstantiateIn(System.Web.UI.Control pContainer)
{
switch (_gtcp.ColumnType)
{
case CommonParameters.RadGridTemplateColumnType.ItemTemplate:
{
_lbl = new Label();
_lbl.CssClass = "ColumnText";
_lbl.Width = new System.Web.UI.WebControls.Unit(_gtcp.Width);
_lbl.ParentType = CommonParameters.BloccoParentType.RadGrid;
_lbl.DataBinding += new EventHandler(Lbl_DataBinding);
pContainer.Controls.Add(_lbl);
}
break;
case CommonParameters.RadGridTemplateColumnType.EditItemTemplate:
{
_txb = new TextBox();
_txb.ID = "txb" + _gtcp.DataField;
_txb.Width = new System.Web.UI.WebControls.Unit(_gtcp.Width);
_txb.DataBinding += new EventHandler(Txb_DataBinding);
_txb.MaxLength = _gtcp.MaxLength;
switch (_gtcp.ReadOnlyOn)
{
case CommonParameters.ReadOnlyTemplateMode.All:
{
_txb.ReadOnly = true;
} break;
case CommonParameters.ReadOnlyTemplateMode.Item:
{
} break;
default: throw new NotImplementedException("ReadOnlyOn non ancora gestita in tutte le tipologie");
}
pContainer.Controls.Add(_txb);
if (_gtcp.Required)
{
RequiredFieldValidator rfv = new RequiredFieldValidator();
rfv.ID = "rfv" + _gtcp.DataField;
rfv.CssClass = "ValidatorStyle";
rfv.ControlToValidate = "txb" + _gtcp.DataField;
rfv.Text = "!";
rfv.ErrorMessage = _gtcp.LabelText + " è obbligatorio!";
rfv.Display = ValidatorDisplay.Static;
pContainer.Controls.Add(rfv);
}
if (_gtcp.Codice)
{
RegularExpressionValidator rev = new RegularExpressionValidator();
rev.ID = "rev" + _gtcp.DataField;
rev.ControlToValidate = "txb" + _gtcp.DataField;
rev.Text = "!";
rev.CssClass = "ValidatorStyle";
rev.ErrorMessage = _gtcp.LabelText + " contiene caratteri non validi!";
rev.Display = ValidatorDisplay.Static;
rev.ValidationExpression = "^[^\\/*?\"<>|]*$";
pContainer.Controls.Add(rev);
}
} break;
}
}
void Lbl_DataBinding(object sender, EventArgs e)
{
Telerik.Web.UI.GridDataItem item = _lbl.NamingContainer as Telerik.Web.UI.GridDataItem;
if (DataBinder.Eval(item.DataItem, _gtcp.DataField) != null)
{
_lbl.Text = DataBinder.Eval(item.DataItem, _gtcp.DataField).ToString();
}
}
void Txb_DataBinding(object sender, EventArgs e)
{
Telerik.Web.UI.GridItem item = _txb.NamingContainer as Telerik.Web.UI.GridItem;
if (item is Telerik.Web.UI.GridDataItem)
{
object value = DataBinder.Eval(item.DataItem, _gtcp.DataField);
if ((value != DBNull.Value) && (value != null))
{
_txb.Text = value.ToString();
}
else
{
_txb.Text = "";
}
}
}
#endregion
}
winIBRouteRF.show();
}
This works fine until i introduced RadAjaxManager. I couldn't find the reference to the window anymore.
It keeps returning null. The solution to this is if i place the above function outisde of the form tag,
just below </form>. I cannot place this function on the bottom page due to my project requirement.
Actually, not only radwindow, but sometimes, other objects just cannot be found using $find. I have to use
onclientload event in order to get the reference. But unfortunately for radwindow, this event doesn't exist.
I've tried to place the function in Sys.Application.add_load but it doesn't help.
Any suggestions?
Thanks.
PS: I'm not using RadWindowManager, just RadWindow.
Regards,
Dexter