【问题标题】:I want to make a redirection webform2 that shows a message based on the gender chosen in radiobutton in webform1我想制作一个重定向 webform 2,它根据 webform1 单选按钮中选择的性别显示一条消息
【发布时间】:2021-05-12 15:30:19
【问题描述】:

这是webform1 代码,我创建了一个名为 pass 的字符串来存储文本。我应该在webform2 中做什么以根据条件显示消息?

protected void Button1_Click(object sender, EventArgs e)
{    
    Response.Redirect("two.aspx", true);
    if (Request.Form["TextBox1"] != null && Request.Form["TextBox2"] != null) 
    {
        if (RadioButton2.Checked)
        {
            //pass = Response.ToString().Insert(Response.ToString().Count(), " " + "Welcome, " + Server.HtmlEncode(Request.QueryString["TextBox1"]) + ". <br/> The url is " + Server.HtmlEncode(Request.Url.ToString()));
            pass = "Thank you Ms. " + TextBox1.Text + "Your Registration has been successfully completed" ;
        }
        else if (RadioButton1.Checked)
        {
            pass = "Thank you Mr. " + TextBox1.Text + "Your Registration has been successfully completed";
        }                    
    }
}

【问题讨论】:

    标签: c# visual-studio webforms textbox


    【解决方案1】:
    Based on whatever i understand, i am providing some solution:
    
    in webform1.aspx:->place below code last line before closing the function
     Application["pass_value"] = pass;
     Response.Redirect("~/webform2");
     Response.Redirect("two.aspx", true);->Not required
    
    in webform2.aspx:
    Label1.Text = Application["pass_value"].ToString();
    
    in webform2.aspx.cs design page:
    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多