ASP.NET CodeBehind C#: How to get cell values of HTML Table from codebehind?
For example this is the table:
<table id="users">
<thead>
<tr class="ui-widget-header ">
<th>Name</th>
<th>Email</th>
<th>Password</th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="text" value="Name1"/></td>
<td><input type="text" value="Email1"/></td>
<td><input type="text" value="Password1"/></td>
</tr> <tr>
<td><input type="text" value="Name2"/></td>
<td><input type="text" value="Email2"/></td>
<td><input type="text" value="Password2"/></td>
<tr>
</tbody>
</table>
then I want the codebehind to get the values from the table.. please help.
html asp.net html-table code-behind
add a comment |
For example this is the table:
<table id="users">
<thead>
<tr class="ui-widget-header ">
<th>Name</th>
<th>Email</th>
<th>Password</th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="text" value="Name1"/></td>
<td><input type="text" value="Email1"/></td>
<td><input type="text" value="Password1"/></td>
</tr> <tr>
<td><input type="text" value="Name2"/></td>
<td><input type="text" value="Email2"/></td>
<td><input type="text" value="Password2"/></td>
<tr>
</tbody>
</table>
then I want the codebehind to get the values from the table.. please help.
html asp.net html-table code-behind
i tried foreach(Contron ctrl in users.Control).. but its not working
– Japs Asuncion
Apr 21 '12 at 11:15
add a comment |
For example this is the table:
<table id="users">
<thead>
<tr class="ui-widget-header ">
<th>Name</th>
<th>Email</th>
<th>Password</th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="text" value="Name1"/></td>
<td><input type="text" value="Email1"/></td>
<td><input type="text" value="Password1"/></td>
</tr> <tr>
<td><input type="text" value="Name2"/></td>
<td><input type="text" value="Email2"/></td>
<td><input type="text" value="Password2"/></td>
<tr>
</tbody>
</table>
then I want the codebehind to get the values from the table.. please help.
html asp.net html-table code-behind
For example this is the table:
<table id="users">
<thead>
<tr class="ui-widget-header ">
<th>Name</th>
<th>Email</th>
<th>Password</th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="text" value="Name1"/></td>
<td><input type="text" value="Email1"/></td>
<td><input type="text" value="Password1"/></td>
</tr> <tr>
<td><input type="text" value="Name2"/></td>
<td><input type="text" value="Email2"/></td>
<td><input type="text" value="Password2"/></td>
<tr>
</tbody>
</table>
then I want the codebehind to get the values from the table.. please help.
html asp.net html-table code-behind
html asp.net html-table code-behind
edited Dec 16 '17 at 9:02
Brian Tompsett - 汤莱恩
4,2331338101
4,2331338101
asked Apr 21 '12 at 11:01
Japs AsuncionJaps Asuncion
3116
3116
i tried foreach(Contron ctrl in users.Control).. but its not working
– Japs Asuncion
Apr 21 '12 at 11:15
add a comment |
i tried foreach(Contron ctrl in users.Control).. but its not working
– Japs Asuncion
Apr 21 '12 at 11:15
i tried foreach(Contron ctrl in users.Control).. but its not working
– Japs Asuncion
Apr 21 '12 at 11:15
i tried foreach(Contron ctrl in users.Control).. but its not working
– Japs Asuncion
Apr 21 '12 at 11:15
add a comment |
2 Answers
2
active
oldest
votes
Create table to run at server like this
<table id="users" runat="server">
and you will be able to access it using HtmlTable class. Have a look at http://msdn.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmltable%28v=vs.80%29.aspx
add a comment |
You have to use the <asp:TextBox> tag instead of the <input> tags. This enables you to get the values from the text boxes in codebehind.
See the System.Web.UI.WebControls.TextBox documentation on MSDN.
UPDATE:
If you can't change the <input> tags to <asp:TextBox>, you could access the form values posted through Request.Form like this:
Request.Form[valueName]
Where value name is the name of the value posted.
So input text is not possible? Actually Im adding row dynamically using javascript and i cant put there asp tags.. quite similar to this jqueryui.com/demos/dialog/#modal-form
– Japs Asuncion
Apr 21 '12 at 11:11
If you want to access the values from codebehind you can't use<input>. The answer from @Ravindra provides another possibility, but still you can't add a row dynamically from javascript.
– Xharze
Apr 21 '12 at 11:22
$("#users tbody").append("<tr>" + "<td><input type='text'class='customerIDCell'/></td>" + "<td><input type='text'class='customerIDCell'/></td>" + "<td><input type='text'class='customerIDCell'/></td>" + "</tr>"); This is how i create row and its working but i cant change that input to aspTextbox I keep using input
– Japs Asuncion
Apr 21 '12 at 11:32
You could useRequest.Formto access the values posted through the form. See msdn.microsoft.com/en-us/library/….
– Xharze
Apr 21 '12 at 11:36
Im will try this, btw thanks for your replies :D
– Japs Asuncion
Apr 21 '12 at 11:43
|
show 1 more comment
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f10258338%2fasp-net-codebehind-c-how-to-get-cell-values-of-html-table-from-codebehind%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Create table to run at server like this
<table id="users" runat="server">
and you will be able to access it using HtmlTable class. Have a look at http://msdn.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmltable%28v=vs.80%29.aspx
add a comment |
Create table to run at server like this
<table id="users" runat="server">
and you will be able to access it using HtmlTable class. Have a look at http://msdn.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmltable%28v=vs.80%29.aspx
add a comment |
Create table to run at server like this
<table id="users" runat="server">
and you will be able to access it using HtmlTable class. Have a look at http://msdn.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmltable%28v=vs.80%29.aspx
Create table to run at server like this
<table id="users" runat="server">
and you will be able to access it using HtmlTable class. Have a look at http://msdn.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmltable%28v=vs.80%29.aspx
answered Apr 21 '12 at 11:05
Ravindra GullapalliRavindra Gullapalli
7,89433261
7,89433261
add a comment |
add a comment |
You have to use the <asp:TextBox> tag instead of the <input> tags. This enables you to get the values from the text boxes in codebehind.
See the System.Web.UI.WebControls.TextBox documentation on MSDN.
UPDATE:
If you can't change the <input> tags to <asp:TextBox>, you could access the form values posted through Request.Form like this:
Request.Form[valueName]
Where value name is the name of the value posted.
So input text is not possible? Actually Im adding row dynamically using javascript and i cant put there asp tags.. quite similar to this jqueryui.com/demos/dialog/#modal-form
– Japs Asuncion
Apr 21 '12 at 11:11
If you want to access the values from codebehind you can't use<input>. The answer from @Ravindra provides another possibility, but still you can't add a row dynamically from javascript.
– Xharze
Apr 21 '12 at 11:22
$("#users tbody").append("<tr>" + "<td><input type='text'class='customerIDCell'/></td>" + "<td><input type='text'class='customerIDCell'/></td>" + "<td><input type='text'class='customerIDCell'/></td>" + "</tr>"); This is how i create row and its working but i cant change that input to aspTextbox I keep using input
– Japs Asuncion
Apr 21 '12 at 11:32
You could useRequest.Formto access the values posted through the form. See msdn.microsoft.com/en-us/library/….
– Xharze
Apr 21 '12 at 11:36
Im will try this, btw thanks for your replies :D
– Japs Asuncion
Apr 21 '12 at 11:43
|
show 1 more comment
You have to use the <asp:TextBox> tag instead of the <input> tags. This enables you to get the values from the text boxes in codebehind.
See the System.Web.UI.WebControls.TextBox documentation on MSDN.
UPDATE:
If you can't change the <input> tags to <asp:TextBox>, you could access the form values posted through Request.Form like this:
Request.Form[valueName]
Where value name is the name of the value posted.
So input text is not possible? Actually Im adding row dynamically using javascript and i cant put there asp tags.. quite similar to this jqueryui.com/demos/dialog/#modal-form
– Japs Asuncion
Apr 21 '12 at 11:11
If you want to access the values from codebehind you can't use<input>. The answer from @Ravindra provides another possibility, but still you can't add a row dynamically from javascript.
– Xharze
Apr 21 '12 at 11:22
$("#users tbody").append("<tr>" + "<td><input type='text'class='customerIDCell'/></td>" + "<td><input type='text'class='customerIDCell'/></td>" + "<td><input type='text'class='customerIDCell'/></td>" + "</tr>"); This is how i create row and its working but i cant change that input to aspTextbox I keep using input
– Japs Asuncion
Apr 21 '12 at 11:32
You could useRequest.Formto access the values posted through the form. See msdn.microsoft.com/en-us/library/….
– Xharze
Apr 21 '12 at 11:36
Im will try this, btw thanks for your replies :D
– Japs Asuncion
Apr 21 '12 at 11:43
|
show 1 more comment
You have to use the <asp:TextBox> tag instead of the <input> tags. This enables you to get the values from the text boxes in codebehind.
See the System.Web.UI.WebControls.TextBox documentation on MSDN.
UPDATE:
If you can't change the <input> tags to <asp:TextBox>, you could access the form values posted through Request.Form like this:
Request.Form[valueName]
Where value name is the name of the value posted.
You have to use the <asp:TextBox> tag instead of the <input> tags. This enables you to get the values from the text boxes in codebehind.
See the System.Web.UI.WebControls.TextBox documentation on MSDN.
UPDATE:
If you can't change the <input> tags to <asp:TextBox>, you could access the form values posted through Request.Form like this:
Request.Form[valueName]
Where value name is the name of the value posted.
edited Apr 21 '12 at 11:38
answered Apr 21 '12 at 11:04
XharzeXharze
2,59411230
2,59411230
So input text is not possible? Actually Im adding row dynamically using javascript and i cant put there asp tags.. quite similar to this jqueryui.com/demos/dialog/#modal-form
– Japs Asuncion
Apr 21 '12 at 11:11
If you want to access the values from codebehind you can't use<input>. The answer from @Ravindra provides another possibility, but still you can't add a row dynamically from javascript.
– Xharze
Apr 21 '12 at 11:22
$("#users tbody").append("<tr>" + "<td><input type='text'class='customerIDCell'/></td>" + "<td><input type='text'class='customerIDCell'/></td>" + "<td><input type='text'class='customerIDCell'/></td>" + "</tr>"); This is how i create row and its working but i cant change that input to aspTextbox I keep using input
– Japs Asuncion
Apr 21 '12 at 11:32
You could useRequest.Formto access the values posted through the form. See msdn.microsoft.com/en-us/library/….
– Xharze
Apr 21 '12 at 11:36
Im will try this, btw thanks for your replies :D
– Japs Asuncion
Apr 21 '12 at 11:43
|
show 1 more comment
So input text is not possible? Actually Im adding row dynamically using javascript and i cant put there asp tags.. quite similar to this jqueryui.com/demos/dialog/#modal-form
– Japs Asuncion
Apr 21 '12 at 11:11
If you want to access the values from codebehind you can't use<input>. The answer from @Ravindra provides another possibility, but still you can't add a row dynamically from javascript.
– Xharze
Apr 21 '12 at 11:22
$("#users tbody").append("<tr>" + "<td><input type='text'class='customerIDCell'/></td>" + "<td><input type='text'class='customerIDCell'/></td>" + "<td><input type='text'class='customerIDCell'/></td>" + "</tr>"); This is how i create row and its working but i cant change that input to aspTextbox I keep using input
– Japs Asuncion
Apr 21 '12 at 11:32
You could useRequest.Formto access the values posted through the form. See msdn.microsoft.com/en-us/library/….
– Xharze
Apr 21 '12 at 11:36
Im will try this, btw thanks for your replies :D
– Japs Asuncion
Apr 21 '12 at 11:43
So input text is not possible? Actually Im adding row dynamically using javascript and i cant put there asp tags.. quite similar to this jqueryui.com/demos/dialog/#modal-form
– Japs Asuncion
Apr 21 '12 at 11:11
So input text is not possible? Actually Im adding row dynamically using javascript and i cant put there asp tags.. quite similar to this jqueryui.com/demos/dialog/#modal-form
– Japs Asuncion
Apr 21 '12 at 11:11
If you want to access the values from codebehind you can't use
<input>. The answer from @Ravindra provides another possibility, but still you can't add a row dynamically from javascript.– Xharze
Apr 21 '12 at 11:22
If you want to access the values from codebehind you can't use
<input>. The answer from @Ravindra provides another possibility, but still you can't add a row dynamically from javascript.– Xharze
Apr 21 '12 at 11:22
$("#users tbody").append("<tr>" + "<td><input type='text'class='customerIDCell'/></td>" + "<td><input type='text'class='customerIDCell'/></td>" + "<td><input type='text'class='customerIDCell'/></td>" + "</tr>"); This is how i create row and its working but i cant change that input to aspTextbox I keep using input
– Japs Asuncion
Apr 21 '12 at 11:32
$("#users tbody").append("<tr>" + "<td><input type='text'class='customerIDCell'/></td>" + "<td><input type='text'class='customerIDCell'/></td>" + "<td><input type='text'class='customerIDCell'/></td>" + "</tr>"); This is how i create row and its working but i cant change that input to aspTextbox I keep using input
– Japs Asuncion
Apr 21 '12 at 11:32
You could use
Request.Form to access the values posted through the form. See msdn.microsoft.com/en-us/library/….– Xharze
Apr 21 '12 at 11:36
You could use
Request.Form to access the values posted through the form. See msdn.microsoft.com/en-us/library/….– Xharze
Apr 21 '12 at 11:36
Im will try this, btw thanks for your replies :D
– Japs Asuncion
Apr 21 '12 at 11:43
Im will try this, btw thanks for your replies :D
– Japs Asuncion
Apr 21 '12 at 11:43
|
show 1 more comment
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f10258338%2fasp-net-codebehind-c-how-to-get-cell-values-of-html-table-from-codebehind%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
i tried foreach(Contron ctrl in users.Control).. but its not working
– Japs Asuncion
Apr 21 '12 at 11:15