Click here to Skip to main content
15,895,973 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have to change the Text of the Button fields when I made the payment


I have button fields with Name: repayment as soon as I click the link it should change to paid (text of button)
Posted
Updated 10-Feb-11 13:37pm
Comments
Sergey Alexandrovich Kryukov 10-Feb-11 12:47pm    
What, reading help on Button was a problem?!
--SA

You can do it either using javascript through getElementById function or by using the click event handler in the code behind. Show something you have already tried and we can pont the problem and solution to you.
 
Share this answer
 
Is it that difficult? I am not sure if this is a client side/server side button control.

For Server Side,
TextBoxName.Text = "whatever";


For Client Side,
TextBoxName.value = "whatever";
 
Share this answer
 
Comments
Monjurul Habib 10-Feb-11 15:57pm    
Text of Button not TextBox, anyway concept is same.
Define a Javascript method to OnClientClick property of button.
In the Javascript method, just change the text of the button. Done! Try!


BTW,
I would suggest you to change the text once payment is done and not just on click.
 
Share this answer
 
Please try the following:

.aspx
XML
<input id="btnRepayment1" type="submit" value="Repayment" runat="server" onserverclick="btnRepayment1_Click" />
      <asp:Button ID="btnRepayment2" runat="server" Text="Repayment" onclick="btnRepayment2_Click" />


.cs
C#
protected void btnRepayment1_Click(object sender, EventArgs e)
   {
       btnRepayment1.Value = "Paid";
   }
   protected void btnRepayment2_Click(object sender, EventArgs e)
   {
       btnRepayment2.Text = "Paid";
   }


If this would be really helpful to you then don't forgot to Vote and Make Answer as Accepted.
 
Share this answer
 
OP said: I have button fields with Name: repayment as soon as i click the link it should change to paid (text of button)

I see big issue with your requirement. You want to change button text from 'Repayment' to 'Paid'. I don't know anything about your application, but that does not smell right. I am assuming on the button click event you are going to process something, right? So why do you want to change button text before you finish processing? What if the process does complete? Or it throw an exception?

The right thing to do is have some sort of message somewhere to indicate whatever you want to indicate. May be you can disable the button when the user clicks it.
 
Share this answer
 
Comments
Rajesh Yerramsetti 10-Feb-11 22:27pm    
i am talk about button field in grid. ok how can i disable the button field

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900