How to change the value of a work in asp.net via javascript?

1

I need to change the text of a label side by Javascript and then reload the page

Follow the label code

<asp:Label runat="server" ID="ValorMax" Visible="false">10</asp:Label>

You need to put this javascript button

<input type="button" id="btn01" value="2" />

I need to click the id="btn01" button to change the value of Label id="ValueMax" from 10 to 20

It reloads the page

    
asked by anonymous 08.10.2017 / 23:15

1 answer

0
  

Quote

When asp:label is rendered, it becomes a tag " span " of HTML .

$(document).ready(function(){
  $('#btn01').click(function(){
    $('#ValorMax').html(20);
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><spanrunat="server" ID="ValorMax" Visible="false">10</span>

<input type="button" id="btn01" value="2" />

I tried to answer your question directly because I know you will use this as an example for more complex things. To reload the page just run the code below, I did not put it in the example because you would not see the value change.

location.reload();

I put JQuery , because it is advisable to use because it speeds development, but there is a way to do with javascript conventional without Framework JQuery .

    
10.10.2017 / 22:26