I have recently installed Txt starter kit on Umbraco 7. In content section of admin page, I created a page of type Text Page under Home. For the page I am limited to only selecting a picture and writing a content. On my former ASP.net website, I had the following code getting some input from user and doing a cost approximation:

<div class="costSection"  runat="server">

            برآورد قیمت ترجمه:
        <br />
           <asp:Label runat="server" Text="نوع ترجمه "></asp:Label>
        <asp:DropDownList ID="ddlTranslationType" runat="server">
                <asp:ListItem Value="0">فارسی به انگلیسی</asp:ListItem>
                <asp:ListItem Value="1">انگلیسی به فارسی</asp:ListItem>
                <asp:ListItem Value="2">فرانسه به فارسی</asp:ListItem>
            <br />
            <asp:Label runat="server" Text="تعداد کلمه "></asp:Label>
        <asp:TextBox ID="txtWordsCount" runat="server"  CssClass="costSection" ></asp:TextBox><br />
        <asp:Button runat="server" ID="btnCalcCost" CssClass="costSection" OnClick="btnCalcCost_Click" Text="محاسبه هزینه"/>
        <asp:Label Text="" ID="lblCost" runat="server" CssClass="costSection"></asp:Label>

And the C# code was:

 protected void btnCalcCost_Click(object sender, EventArgs e)

int userChoice; try{int.TryParse(ddlTranslationType.SelectedValue,out userChoice);} catch(Exception ex){ lblCost.ForeColor = System.Drawing.Color.Red; lblCost.Text=ex.Message; return; } int wordsCount; if (txtWordsCount.Text == null || !int.TryParse(txtWordsCount.Text,out wordsCount)) { lblCost.ForeColor = System.Drawing.Color.Red; lblCost.Text = "لطفا تعداد کلمات را وارد کنید"; return; } float cost=0; switch (userChoice) { case 0: //Farsi-English cost = (float)wordsCount / 250 * 13000; break; case 1: //English-Farsi cost = (float)wordsCount / 300 * 8000; break; case 2: //French-Farsi cost = (float)wordsCount / 250 * 20000; break; } long estimatedCost = (long)cost; lblCost.ForeColor= System.Drawing.Color.Green; lblCost.Text = estimatedCost.ToString()+" تومان "; }

In my new Umbraco post, I want to have this code, but I don't know where to add the markup and the C# code for it to work.

Related posts

Recent Viewed