Hasan Veli
Hasan Veli

Reputation: 11

How to avoid refreshing of textbox value in asp.net when click button?

I have a web form that includes 2 main "div".In first div(DivUser),i have a form that includes textboxes and buttons and in the second div(DivSignature),i get the values from that form and show at the second div when i click on the btn_CreateSignature button in form. I want to avoid refreshing of the textboxes' value in first div but i want to refresh the second div. How can i do that?I have added my code below.Please help me about that issue.

Thanks in advance.

<body>
    <form id="form1" runat="server">
        <div id="DivUser" class="y-container Outer">
            <div class="jumbotron">
                 <asp:ScriptManager runat="server" ID="ScriptManager" />
                <asp:UpdatePanel ID="updPnl" runat="server" UpdateMode="Conditional" RenderMode="Block">
  <ContentTemplate>
           <h5>Hello  <asp:LinkButton ID="lblUserName" ForeColor="Red" runat="server">LinkButton</asp:LinkButton></h5>
      </ContentTemplate>
                    </asp:UpdatePanel>
      <h5><asp:LinkButton ID="btnLogOut" runat="server" ForeColor="Red" CssClass="pull-right" OnClick="btnLogOut_Click" Font-Underline="True">Log Out</asp:LinkButton> </h5>
        <h2><asp:Label ID="lblUser" runat="server" ForeColor="Red"/> - Update User Information</h2>       
        </div>            
      <div class="form-group row InnerLeft" style="margin-left:5px;margin-top:10px;" >
      <div class="form-inline form-group">
  <label class="col-2 col-form-label">User Name</label>
  <input class="form-control col-10"  type="text"  id="inputUsername" style="width:22%;font-size:16px;"  runat="server" required="required"/>
          </div>
              <div class="form-inline form-group">
  <label class="col-2 col-form-label">Name</label>
  <input class="form-control col-10"  type="text"  id="inputName" style="margin-left:75px;width:22%;font-size:16px;" runat="server" required="required"/>
          </div>
              <div class="form-inline form-group">
  <label class="col-2 col-form-label">Surname</label>
  <input class="form-control col-10"  type="text"  id="inputSurname" style="margin-left:48px;width:22%;font-size:16px;" runat="server" required="required"/>
          </div>  
                <div class="form-inline form-group">
  <label class="col-2 col-form-label">Title</label>
  <input class="form-control col-10"  type="text"  id="inputTitle" style="margin-left:48px;width:42%;font-size:16px;" runat="server" required="required"/>
          </div> 
               <div class="form-inline form-group">
  <label class="col-2 col-form-label">Email</label>
  <input class="form-control col-10"  type="email"  id="inputEmail" style="margin-left:52px;width:42%;font-size:16px;" runat="server" required="required"/>
          </div> 
             <div class="form-inline form-group">
  <label class="col-2 col-form-label">Phone</label>
  <input class="form-control col-10"  type="tel"  id="inputPhone" style="margin-left:40px;width:22%;font-size:16px;" runat="server" required="required"/>
          </div> 
         <label class="col-2 col-form-label">Update Password</label>           
         <asp:Button   ID="btn_UpdatePassword" class="btn btn-success"  runat="server" OnClick="btn_UpdatePassword_Click" Text="Update Password"/> 
           <p /><br />
          <label class="col-2 col-form-label">Create Signature</label>           
         <asp:Button   ID="btn_CreateSignature" class="btn btn-warning leftmargin"   runat="server" OnClick="btn_CreateSignature_Click" Text="Create Signature"/> 
          <p /><br />
           <asp:Button ID="btn_Update" class="btn btn-primary" Text="Update" runat="server" OnClick="btn_Update_Click" />&nbsp;
           <asp:Button ID="btn_Cancel" class="btn btn-primary" Text="Cancel" OnClick="btn_Cancel_Click" runat="server"/>
                </div>
            <div class="InnerRight" style="width:425px;height:260px;">
                             <div id="divSignature" class="x-container" style="margin-top:10px;padding-top:10px; width:425px;height:260px;background-color:White;">
        <div class="row">
            <div>
                <img style="width: 140px" src="images/logo_signature.png"/>
            </div>
            <div style="margin-left: 15px">
                <div class="x-container">
                    <div class="row">
                        <div>
                            <div class="x-container">
                                <div class="row">
                                    <h5>
                                     <strong><asp:Label ID="lblName" runat="server" style="font-family:'Times New Roman'"></asp:Label></strong>
                                    </h5>
                                </div>
                                <div class="row" style="margin-top: -10px">
                                    <p>
                                        <asp:Label ID="lblTitle" runat="server" style="font-family:'Times New Roman'"></asp:Label>                
                                    </p>
                                </div>
                                <hr style="margin-top: -10px;"/>
                                <div class="row" style="margin-top: -15px">
                                        <p>
                                            <strong>M&nbsp;:</strong><p> <asp:Label ID="lblPhone" runat="server" style="font-family:'Times New Roman'"></asp:Label></p>
                                        </p>
                                </div>
                                <div class="row"  style="margin-top: -20px">
                                        <p>
                                            <strong>T&nbsp;&nbsp;: </strong><p style="font-family:'Times New Roman'">  +00 000 00 00</p>
                                        </p>
                                    </div>

                                <div class="row"  style="margin-top: -20px">
                                        <p>
                                            <strong>E &nbsp;:&nbsp;</strong><p> <asp:Label ID="lblEmail" runat="server" style="font-family:'Times New Roman'"></asp:Label> </p>
                                        </p>
                                    </div>
                                    <div class="row"  style="margin-top: -20px">
                                            <p>
                                                <strong>W:&nbsp;</strong><p style="font-family:'Times New Roman'"> www.website.com</p>
                                            </p>
                                        </div>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
            
        </div>
        <div class="row" style="margin-top: 0px; margin-left: 1px;font-size:12px;">
            <div class="x-container">
                <div class="row">
                        <div style="align-self: center;font-family:'Times New Roman'" >
                             Address<br/>
                        </div>      
                        <div style="margin-left: 15px;">
                                <img width="70" src="images/qr_code.png"/>    
                        </div>        
                </div>
            </div>
        </div>
        <div class="row" style="margin-top: 0px; margin-left: 0px" >
                <img style="width: 400px" src="images/seritt.png"/>
        </div>
    </div>
                </div>
            </div>
    </form>
</body>

Upvotes: 0

Views: 550

Answers (1)

Levidoom
Levidoom

Reputation: 84

Ok, First change the

<input> 

tags to

<asp:textbox id="controlID" runat="server"> 

now in the .cs (or .vb) file you will save all the values of these textbox to a session state.

Session["SessionName"] = textBox1.Text;

And after that you will fill the controls in the Page_Load method:

if(!isPostBack){
 textBox1.Text = Session["SessionName"];
}

You can, if you have more than one TextBox store the values in an array and then store the array in a session.

hope this helps ;)

Upvotes: 1

Related Questions