I want when the button is clicked a string comes on the textbox based on user selection, I don't know how to do that this is the code:
protected void Button1_Click(object sender, EventArgs e)
{
//DECLARE A STRING VARIABLE
String choice = "";
//LET THE USER SELECT BETWEEN TWO VALUES TO DISPLAY PRICE OF THE BOOK
Response.Write("<script>choice=window.prompt('Which Currency you want the price display ? 1 : Dollar or 2: Euro');" + "if(choice=='1'){ document.writeln('$22.43');}" + "if(choice=='2') document.write(' 20.55 EUR');" + "</script>");
}
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
}
Try this:
string yourString = "heyheyhey"; TextBoxName.Text = yourString;
1.Use label and edit text from label1 to Which Currency you want the price display? 1: Dollar or 2: Euro.
2.Use another label in which you want display the currency and name it as lbl_currency.
3.Use a text box and name it as txt_choice.
4.use button name it as btn,double click button and in the click event enter this code.
protected void btn_Click(object sender, EventArgs e)
{
if(Convert.ToInt32(txt_choice.Text)==1){
lbl_currency.Text="$22.43";
}
else if(Convert.ToInt32(txt_choice.Text)==2){
lbl_currency.Text="20.55 EUR";
}
else{
MessageBox.Show("Wrong Input");
}
}
You need to have control called RadioButtonList for selecting your currency then in code behide
protected void btn_Click(object sender, EventArgs e)
{
if(yourID_RadioButtonList.SelectedValue)=="Something"){
lbl_currency.Text="Your_Value1";
}
else {
lbl_currency.Text="Your_Value2";
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.