Reputation:
The value must be retrived from javascript alert to textbox without losing runat="server". code as follow
<script type="text/javascript">
$(".btn-group > button.btn").on("click", function () {
var name = this.innerHTML; ;
$('#TextBox1').html(name);
});
</script>
Upvotes: 0
Views: 629
Reputation: 11104
<script type="text/javascript">
$(".btn-group > button.btn").on("click", function () {
var name = this.innerHTML; ;
// Use `val()` instead of html
// Use `ClientID ` to use textbox generated id in javascript
$('#<%= TextBox1.ClientID%>').val(name);
});
</script>
Upvotes: 1
Reputation: 407
$('#TextBox1').val(name);
Use the value method to set the content of the text box
Upvotes: 0