請大家幫幫忙,要如何寫才能讓Radio button在不同url進入後顯示的字不同?
這是我的radio button,rescources為語系檔
<asp:RadioButton ID="rbt_kind_2" runat="server" GroupName="1" Text="<%$ Resources:2021, rbt_kind_2 %>" AutoPostBack="true"/>
aspx.cs(要怎麼寫?寫在哪?)
if (oSec.code_type.ToLower() == "a1"){
....
}
else{
....
}
謝謝
asp.net要如何寫才能讓Radio button在不同url進入後顯示的字不同?
ASPX
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Page.aspx.cs" Inherits="MyNamespace.Page" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>
<!DOCTYPE html>
<html>
<head runat="server">
<title>Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:RadioButton ID="rbt_kind_2" runat="server" GroupName="1" Text='<%# codeType == "a1" ? Resources.2021.rbt_kind_2 : (codeType == "a2" ? Resources.2021.rbt_kind_2_alt : Resources.2021.rbt_kind_2_default) %>' AutoPostBack="true"/>
</div>
</form>
</body>
</html>
ASPX.CS
protected void Page_Load(object sender, EventArgs e)
{
string codeType = Request.QueryString["CODE_TYPE"];
if (codeType == "a1")
{
rbt_kind_2.Text = Resources.2021.rbt_kind_2;
}
else if (codeType == "a2")
{
rbt_kind_2.Text = Resources.2021.rbt_kind_2_alt;
}
else
{
rbt_kind_2.Text = Resources.2021.rbt_kind_2_default;
}
DataBind();
}