[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 931
  • Last Modified:

Help with passing data to a masked textbox

Hi,

I am able to select data from a listbox and pass it to a regular textbox (ItemA) using the code below,

ItemA.Text = ListBox1.SelectedItem.Text

However the code doesn't work with a masked input box, how do modify the code to pass the value selected from a listbox to a masked input box? I am using ASP.NET.

V.
0
vcharles
Asked:
vcharles
  • 4
  • 4
2 Solutions
 
Roopesh ReddyCommented:
Hi,

Please check the below sample code!

<ajaxToolkit:ToolkitScriptManager runat="server" ID="scriptManager1">
    </ajaxToolkit:ToolkitScriptManager>

    <asp:TextBox runat="server" ID="txtBox"></asp:TextBox>

    <ajaxToolkit:MaskedEditExtender runat="server" ID="maskedTextBox" MaskType="Number" Mask="99.99" TargetControlID="txtBox">
    </ajaxToolkit:MaskedEditExtender> 

 
//Code behind - Initialing the value
protected void Page_Load(object sender, EventArgs e)
        {
            txtBox.Text = "11.11";
}

Open in new window


Hope it helps u...
0
 
vcharlesAuthor Commented:
Hi,

My problem is what is the correct code to pass it the data from the textbox to the listbox when the textbox is masked? The sample code does not tranfer the data the listbox.

Thanks.
0
 
Roopesh ReddyCommented:
Hi,

Check the sample code, which is working fine for me!

 <asp:TextBox runat="server" ID="txtBox"></asp:TextBox>

    <ajaxToolkit:MaskedEditExtender runat="server" ID="maskedTextBox" MaskType="Number" Mask="99.99" TargetControlID="txtBox">
    </ajaxToolkit:MaskedEditExtender> 


    <asp:ListBox runat="server" ID="listbox" >
        <asp:ListItem Text="text1" />
        <asp:ListItem Text="text2" />
    </asp:ListBox>

    <asp:Button runat="server" Text="Add" OnClick="btnClick" />

//Copy the Masked textbox data to Listbox
 protected void btnClick(object sender, EventArgs e)
        {
            listbox.Items.Add(txtBox.Text);
        }

Open in new window


Hope it helps u...
0
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
vcharlesAuthor Commented:
Sorry, I meant what is the proper code to copy selected item from a listbox to a Masked InputBox?
0
 
Roopesh ReddyCommented:
Hi,

Then try the following code!

Use the same code above, but the button click handler changed

 protected void btnClick(object sender, EventArgs e)
        {
            //Copy the selected value to Masked text box!
            txtBox.Text = listbox.SelectedValue;
        }

Open in new window


Hope it helps u...
0
 
vcharlesAuthor Commented:
I need the text, not the value. This code works when the input control is unmasked, any ideas why it does not work when the control is masked?

C1NSNA.Text = C1NSN.SelectedItem.Text

Thanks.
0
 
Roopesh ReddyCommented:
Hi,

You may have to try the following code!

txtBox.Text = listbox.SelectedItem.Text

Open in new window


Hope it helps u...
0
 
vcharlesAuthor Commented:
Hi,

Could not figure the answer from the link, contacted componentone. waitinf to hear bacl from them.
0

Featured Post

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now