Click here to Skip to main content
15,914,405 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i can add command name & command argument in text box
XML
<asp:TextBox ID="txtpacks" runat="server" SkinID="smalltextBox60px" Text='<%#Eval("Packs") %>'
                                                                                               OnTextChanged="txtPacksunits_textchanged" CommandName="1" CommandArgument="pack"  AutoPostBack="true" MaxLength="9"></asp:TextBox>


XML
<asp:TextBox ID="txtunits" runat="server" SkinID="smalltextBox60px" Text='<%#Eval("Units") %>'
                                                                                               OnTextChanged="txtPacksunits_textchanged" CommandName="2" CommandArgument="units" AutoPostBack="true" MaxLength="9"></asp:TextBox>



same text change event for two text boxes.
I want code for which text box is faired in Chande event .
please help me
Posted

1 solution

Hey there,

I am not sure why do you need CommandName and CommandArgument for TextBox, as these are not properties of TextBox control, so CommandName and CommandArgument will be added as Attributes of the TextBox.
Here is an example showing how you can get them in the event:
C#
protected void TextBox_TextChanged(object sender, EventArgs e)
        {
            TextBox txt = (TextBox) sender;
            string commandArg = txt.Attributes["CommandArgument"].ToString();
            String commandName = txt.Attributes["CommandName"].ToString();
        }


Let me know if it helps.

Azee...
 
Share this answer
 
v2
Comments
MANI 14 12-Oct-13 4:44am    
i want to find which text box get fair and then assign focus to next text box. These are used in gridview. So, how to find which text box changed please help me
Azee 12-Oct-13 4:47am    
You can use CommandArgument or CommandName's value to identify which TextBox was changed. I have shown you how to get those values. What is the problem now?
and What is the parent control of these TextBoxes?
MANI 14 12-Oct-13 4:56am    
kk its working fine. Thank you......... Azee
Azee 12-Oct-13 4:59am    
Great, cheers.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900