RadTextBox Populating Values

2 posts, 0 answers
  1. Sudhakar
    Sudhakar avatar
    28 posts
    Member since:
    Jul 2014

    Posted 22 Oct 2014 Link to this post

    Hi Team,

    I am having three text boxes in the form.
    I need to populate the other two text box values based on the value in the first text box value.
    These values are coming from database.

      <tr class="FormContainer">
                        <td style="white-space: nowrap;">
                            Terminal ID:
                            <telerik:RadTextBox ID="txtTerminalId" runat="server" >
                            <asp:RequiredFieldValidator ID="txtTerminalIdValidator" runat="server" Display="Dynamic"
                                ControlToValidate="txtTerminalId" ErrorMessage="TerminalId can not be empty!"></asp:RequiredFieldValidator>
                    </tr>                <tr class="FormContainer">
                        <td style="white-space: nowrap;">
                            Terminal Name:
                            <telerik:RadTextBox ID="txtTerminalName" runat="server"></telerik:RadTextBox>
                    </tr>                <tr class="FormContainer">
                        <td style="white-space: nowrap;">
                            Terminal Address:
                            <telerik:RadTextBox ID="txtTerminalAddress" runat="server"></telerik:RadTextBox>
    When i Type Terminal Id in the textbox,Terminal name and terminal address needs to populate automatically.
    These values are coming from the database.

    protected void plantIdChanged(object sender, EventArgs e)
            Int64 plant_id = Convert.ToInt64(txtTerminalId.Text);        var depots = loadingManager.GetLoadingSite(plant_id).FirstOrDefault(x => x.Plant_ID == plant_id);
            if (depots != null)
                txtTerminalName.Text = depots.PlantText;
                txtTerminalAddress.Text = depots.Street + " " + depots.Zipcode;
    plantIdChanged m
    ethod is used for get terminal name and terminal address from database based on the terminalid(plant_id).
    Need to implement it in Onblur event of the text box.

    Can any one please help,how to implement this.

  2. Viktor Tachev
    Viktor Tachev avatar
    1445 posts

    Posted 27 Oct 2014 Link to this post

    Hello Sudhakar,

    In order to implement the described functionality you can handle the OnTextChanged event for RadTextBox. Note that in order for the event to be triggered you should set the AutoPostBack property to true. The markup for the first RadTextBox control would look similar to the following:

    <telerik:RadTextBox ID="txtTerminalId" runat="server" OnTextChanged="plantIdChanged" AutoPostBack="true"></telerik:RadTextBox>

    Try this approach and you should be able to implement the functionality you are looking for.

    Viktor Tachev

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

  3. DevCraft R3 2016 release webinar banner
Back to Top