2017-04-13 69 views
1

你能告訴我什麼是壞的?我只需要檢查按鈕選擇語言以在下一個網站上繼續。我怎樣才能獲得輸入電臺的價值C#

HTML

<asp:Content ID="BodyContent" ContentPlaceHolderID="BodySite" runat="server"> 
<h1>Výběr jazyka:</h1> 
<p>Choose language | Sprachauswahl</p> 
<form method="post" action="index.aspx"> 
<div class="checkbox-test"> 
    <table style="border-spacing: 5px; border-collapse: separate;"> 
     <tr> 
      <td> 
       <input type="radio" name="check_lang" id="check_cz" class="css-checkbox" value="cz" /> 
       <label for="check_cz" class="css-label"><img src="http://terquil.cz/images/cz.png" class="img-flag" alt="CZ" /></label> 
      </td> 
      <td><h2>CZ</h2></td> 
     </tr> 
     <tr> 
      <td> 
       <input type="radio" name="check_lang" id="check_en" class="css-checkbox" value="en" /> 
       <label for="check_en" class="css-label"><img src="http://terquil.cz/images/uk.png" class="img-flag" alt="EN" /></label> 

      </td> 
      <td><h2>EN</h2></td> 
     </tr> 
     <tr> 
      <td> 
       <input type="radio" name="check_lang" id="check_de" class="css-checkbox" value="de" /> 
       <label for="check_de" class="css-label"><img src="http://terquil.cz/images/de.png" class="img-flag" alt="DE" /></label> 
      </td> 
      <td><h2>DE</h2></td> 
     </tr> 
    </table> 
</div> 
<input Type="submit" id="language_btn" VALUE="Pokračovat | Continue | Andere" > 
</form> 

C#(我試過,但不工作)

protected void submit(object sender, EventArgs e) 
{ 
    string cz = "cz"; 
    string de = "de"; 
    string en = "en"; 

    if (Request.Form["check_lang"] != null) 
    { 
     string selectLanguage = Request.Form["check_lang"].ToString(); 

     if (selectLanguage == cz) 
      Response.Redirect("http://terquil.cz/cs/index.aspx"); 
     if (selectLanguage == en) 
      Response.Redirect("http://terquil.cz/en/index.aspx"); 
     if (selectLanguage == de) 
      Response.Redirect("http://terquil.cz/cs/index.aspx"); 
    } 
} 

CSS對象組:

input[type=radio].css-checkbox { 
     position:absolute; 
     z-index:-1000; 
     left:-1000px; 
     overflow: hidden; 
     clip: rect(0 0 0 0); 
     height:1px; 
     width:1px; 
     margin:-1px; 
     padding:0; 
     border:0; 
} 

input[type=radio].css-checkbox + label.css-label { 
    padding-left:37px; 
    height:32px; 
    display:inline-block; 
    line-height:32px; 
    background-repeat:no-repeat; 
    background-position: 0 0; 
    font-size:32px; 
    vertical-align:middle; 
    cursor:pointer; 
} 

input[type=radio].css-checkbox:checked + label.css-label { 
    background-position: 0 -32px; 
} 

label.css-label { 
    background-image:url(http://csscheckbox.com/checkboxes/u/csscheckbox_c1a4f40d98f1c23d1ad84d2af9c314be.png); 
    -webkit-touch-callout: none; 
    -webkit-user-select: none; 
    -khtml-user-select: none; 
    -moz-user-select: none; 
    -ms-user-select: none; 
} 

我只需要做,如果有人選擇他的指定語言的電臺,並點擊提交按鈕,所以他會重定向,以指定他的語言的HTML頁面。

+0

你是什麼意思,它不起作用? – Darren

+0

如果我點擊提交按鈕比它不重定向我指定的網頁。 –

+2

如果您調試代碼並逐步完成,您是否獲得了'Request.Form [「check_lang」]' – Pete

回答

0

要麼使用runat="server"訪問它在C#代碼
或者使用JavaScript,你可以在一個隱藏字段,這將是訪問到你的C#代碼存儲的值單選按鈕的變化情況。

$(document).ready(function(){ 
    $('#rdbEnglish').click(function(){ 
     $('#hdn').val('English'); 
    });