Sunday 15 February 2015

asp.net - Extracting Data out of a input box inside a table cell using C# -


I have some tables that look like this:

  & lt; Table width = "650" id = "myTable" runat = "server" & gt; & Lt; Tbody & gt; & Lt; TR & gt; & Lt; Td> & Lt; Input type = "text" / & gt; & Lt; / Td> & Lt; Td> & Lt; Input type = "text" / & gt; & Lt; / Td> & Lt; Td> & Lt; Input type = "text" / & gt; & Lt; / Td> & Lt; Td> & Lt; Input type = "text" / & gt; & Amp; Nbsp; & Lt; / Td> & Lt; / TR & gt; & Lt; TR & gt; & Lt; Td> & Lt; Input type = "text" / & gt; & Lt; / Td> & Lt; Td> & Lt; Input type = "text" / & gt; & Lt; / Td> & Lt; Td> & Lt; Input type = "text" / & gt; & Lt; / Td> & Lt; Td> & Lt; Input type = "text" / & gt; & Amp; Nbsp; & Lt; / Td> & Lt; / TR & gt; & Lt; TR & gt; & Lt; Td> & Lt; Input type = "text" / & gt; & Lt; / Td> & Lt; Td> & Lt; Input type = "text" / & gt; & Lt; / Td> & Lt; Td> & Lt; Input type = "text" / & gt; & Lt; / Td> & Lt; Td> & Lt; Input type = "text" / & gt; & Amp; Nbsp; & Lt; / Td> & Lt; / TR & gt; & Lt; / Tbody & gt; & Lt; / Table & gt;   

Now, I want to rip that data and store it in an XML file. The problem is that the number of rows is unknown. The user can create between 3 and N rows anywhere, to solve it, I wrote a small loop that pulls data based on the line.

  // Assume that the relevant items have been declared and a fair price has been given. While (i   

This problem only after running with me now is that what is inside the input box, not just the actual input box code is in bringing, which is not really what I want .

How do I get content inside the input box?

You can develop some script by grabbing all the text values ​​of the generated text box and assigning them the same ID By and after script ID can get the value. Then store it in a variable that you can enter in your C # code

HTML for your text box and a hidden text-box containing the value of the rest of the text box using the script Can be filled in:

  & lt; Input type = "text" category = "user textbox" /> & Lt; Input type = "hidden" id = "hidden hotbox" />   

Personal preference for JQuery at this point (but I'm pretty sure that you can accomplish something like this with any script):

  $ ('Body') .live ('input', '. Usertxtbox', function () {$ ('# hiddenTxtBox'). Val ($ ('. UserTxtBox'). Val ());});   

Then, in your C # code, you can catch text with hidden text boxes.

No comments:

Post a Comment