Reputation: 1545
I have an aspx page. On it I have a Telerik text box and a label along with many other controls. My requirement is if user types in a 0 or a number which does not exist in my SQL database then an alert should be shown. I mean if user types 0 and tabs alert saying "no zero allowed". If a number like 9393932 entered then check the SQL db and see that the number does not exist in my corresponding table and alert "no customer exists with that number".
<td><telerik:RadNumericTextBox ID="rntbSearchCust" runat="server" AutoPostBack="true" NumberFormat-GroupSeparator="" OnTextChanged="rntbSearchCust_TextChanged" Width="100px" NumberFormat-DecimalDigits="0" /></td>
...
<tr>
<td>
<asp:Label ID="lblCust" runat="server" CssClass="alttabledata" />
</td>
</tr>
...
<telerik:RadAjaxManagerProxy ID="RadAjaxManager1" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="rntbSearchCust">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="lblCust" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManagerProxy>
Also, if customer number exists then the label lblCust
should show the customer name.
protected void rntbSearchCust_TextChanged(object sender, EventArgs e)
{
if (rntbSearchCust.Value > 0)
{...}
else
{
string strError = "Please enter Cust number greater than 0.";
ClientScript.RegisterStartupScript(this.GetType(), "show", "alert('" + strError + "');", true);
}
}
I have debugged the program, it goes into the else part when I put in 0, but I never see the pop up. So I commented the ajax part and then I see the pop up. So, how should I show pop up with ajax still present? If you need more info, please ask.
Upvotes: 0
Views: 1101
Reputation: 3914
I think you should use the RadAjaxManager to run the script like this :
else
{
RadAjaxManager1.ResponseScripts.Add("alert('Please enter Cust number greater than 0.');");
}
Pls give it a try! it should work.
Upvotes: 2