iT邦幫忙

第 12 屆 iThome 鐵人賽

DAY 7
0
Modern Web

零經驗ASP .NET Core 30 DAY全紀錄系列 第 7

零經驗 .NET Core 30 DAY----- Day7 功能設計及採用之c#和html方法介紹

你各位大家好啊,我不好,今天悽悽慘慘悽悽,這個功能我原本是想要用動態的,參考了bootstrap-table以及jQuery,還是無法做出我想要的效果,白白花了不少個小時/images/emoticon/emoticon03.gif,之後有機會我再來研究怎麼做,今天暫且放棄,先來講講我要用來完成”新增座位表的功能” 的簡單方法。

我的流程設計如下

https://ithelp.ithome.com.tw/upload/images/20200913/20130030dEyttKzTYh.png

採用的C#語法

  • 字串跟數字轉換
  //string轉int/float/double
    string before ="123";
    int after = int.Parse(before);//int可換成float/double
   
  //int轉string
    int before= 123;
    string after = Convert.ToString(before);
    
  //double轉string
    double before = 12.5;
    string after  = Convert.ToString(before);

如果想要知道資料的型態可以使用

data.GetType();
  • 字串處理

字串切割,要切割的字串.split(“切割符號”)

    string before = "a,b,c"; 
    string[] after = before.Split(“,”);//以,作為切割符號 
    foreach (var temp in after)
    Console.WriteLine(temp);

字串取代

    string before = "我!愛!你! "; 
    string after =before.Replace("愛", "恨");//用”恨”把”愛”取代掉 
    Console.WriteLine(after);

字串陣列,尋找字串位置 Array.IndexOf(整個字串陣列, "欲得知index之字串")

    string[] before = {"abc","acd","ae"};   
    int index = Array.IndexOf(before, "ae");
    Console.WriteLine(index);

採用的HTML語法

  • 下拉式選單

selected表示預選設定。

<select name="my_option">
        <option value="a">a</option>
        <option value="b" selected>b</option>
</select>

select加入multiple,表示可多選。(多選,在 Windows中是先按住ctrl鍵,再點選選項;在Mac中則是按住command 鍵)

<select name="my_option" multiple>
      <option value="a">a</option>
      <option value="b">b</option>
      <option value="c">c</option>
</select>

select加入size,指定一次讓使用者看到幾個選項,預設值是1;有設定 multiple時,預設值則是4。

<select name=" my_option " multiple size="6">
      <option value="a">a</option>
      <option value="b">b</option>
      <option value="c">c</option>
      <option value="d">d</option>
      <option value="e">e</option>
      <option value="f">e</option>
</select>

上面的程式碼會使得下拉式選單預設出現6個選項。

DAY7心得:
今天的內容廢廢的,放些我做實作會用到的東西,打算用下拉式選單來做座位狀態更改的選擇,明天會實作然後放結果,今天是周末放過自己/images/emoticon/emoticon25.gif,好了我要去找食物吃了,明天見。


上一篇
零經驗 .NET Core 30 DAY----- Day6 SESSION&COOKIE觀念及極簡易登入
下一篇
零經驗 .NET Core 30 DAY----- Day8 功能實作[座位管理系統-新增座位表]
系列文
零經驗ASP .NET Core 30 DAY全紀錄30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言