Click here to Skip to main content
16,003,902 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am creating a Site master page in ASP.NET. In that page there are 5 buttons i.e.,
"Patient
"Doctors"
"Hospitals"
"Pathologist"
"Pharmacist"

Once if i click to Patient Button the Patient Page Has to appear and simultaneously All the 5 button Text Have to Change by following text Respectively.

"Book Appointment With Doctor"
"Book Appointment With Hospitals"
"Book Appointment With Pathologist"
"Order Medicine"
"Free Registration"

i need the C# code
Posted
Updated 15-May-12 21:36pm
v2

C#
Button1.Text = "Some Text";

In this way you can change the button text dynamically.

For your requirement before redirect to the Patient page change the text of the button.
 
Share this answer
 
pls try this

<input id="btnRepayment1" type="submit" value="Repayment" runat="server" onserverclick="btnRepayment1_Click" />
      <asp:button id="btnRepayment2" runat="server" text="Repayment" onclick="btnRepayment2_Click" xmlns:asp="#unknown" />


protected void btnRepayment1_Click(object sender, EventArgs e)
   {
       btnRepayment1.Value = "Paid";
   }
   protected void btnRepayment2_Click(object sender, EventArgs e)
   {
       btnRepayment2.Text = "Paid";
   }
 
Share this answer
 
Comments
Imran D 16-May-12 4:51am    
where i have to write this code...
I have 5 menu buttons in the site master page
"Patient
"Doctors"
"Hospitals"
"Pathologist"
"Pharmacist"

when i click the patient link it is going to the patient page with the same button text and when i move to doctor page, hospital page etc...same button text i am finding, so now i have to change the button text when the user move to the patient page the appropriate menu button text it has to display, like for all the pages i have to change the menu button text... for doing this i am using switch case... please check the below code and help me for this problem...
protected void DynamicMenuChange()
{
switch (DocFixFrameWork.PageState)
{
case PageState.PatientAppointmentWD:
{
this.btnPatient.Text = "Book Appointment With Doctor";
this.btnDoctors.Text = "Book Appointment With Hospitals";
this.btnHospitls.Text = "Book Appointment With Pathologist";
this.btnPathologiest.Text = "Order Medicine";
this.btnPharmacist.Text = "ZA";
}
break;
case PageState.HomePage:

break;
}
Imran..U can try this..Use The session value..i.e.,wen user clicks on respective button..just add the session value..to it..
ex:- on button_click
C#
{
Session["Patient"]="Patient";
response.redirect("PatientPage.aspx");
}

After That in page_init() add this session values to the button.text=Session["Patient"].ToString();

try this..it works..
 
Share this answer
 
v2
You can also do it in a simpler way that when you click on the page and when it is "Postback" you can check the "Button.text" value and replace it with whatever you want and you can also check when in query string you have the URL address of the "Patient.aspx" then you can replace the button text
 
Share this answer
 
The problem you will have in this scenario is that you have to set the value of the new button value in session because you can't get that on content page and when you redirect it you can can simply you can retrieve the value from session and change it in any way you want and take the session variable global so that if you change it the effect is proper.
C#
Session["Patient"]="Patient";

and when you assign it you can do this:
C#
Session["Patient"] = "Book Appointment With Doctor"
 
Share this answer
 
v2
Hi see this format
SQL
switch (value)
 {
     case Patient:
           this.btnPatient.Text = "Book Appointment With Doctor";
          break/jump
     case Doctors:
           this.btnDoctors.Text = "Book Appointment With Hospitals";
          break/jump

     //like this youu can add here remaining cases
     default:
          By default what u want u can write here
          break/jump
 }
 
Share this answer
 
v2

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