Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Placing C# into an ASP.net Form

Placing C# into an ASP.net Form

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netquestionarchitecture
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Paul Harsent
    wrote on last edited by
    #1

    I have a form for which I want the price to resemble the current price of an object. But I cant add any C# into this form. Im building a paypal program using MVC.

    <%if (Roles.IsUserInRole("FullMember") == false)
    {%>

    I want to place

    <% item.price%>

    Into the value-"10.00" place. Is this possialbe and how do I go about doing this? Thanks

    A S 2 Replies Last reply
    0
    • P Paul Harsent

      I have a form for which I want the price to resemble the current price of an object. But I cant add any C# into this form. Im building a paypal program using MVC.

      <%if (Roles.IsUserInRole("FullMember") == false)
      {%>

      I want to place

      <% item.price%>

      Into the value-"10.00" place. Is this possialbe and how do I go about doing this? Thanks

      A Offline
      A Offline
      Ali Al Omairi Abu AlHassan
      wrote on last edited by
      #2

      Do you mean this

      <input type="hidden" name="amount" value="<%= item.price %>" />

      Help people,so poeple can help you.

      P 1 Reply Last reply
      0
      • A Ali Al Omairi Abu AlHassan

        Do you mean this

        <input type="hidden" name="amount" value="<%= item.price %>" />

        Help people,so poeple can help you.

        P Offline
        P Offline
        Paul Harsent
        wrote on last edited by
        #3

        Yes I do, but it doesnt work when I do that.

        A 1 Reply Last reply
        0
        • P Paul Harsent

          Yes I do, but it doesnt work when I do that.

          A Offline
          A Offline
          Ali Al Omairi Abu AlHassan
          wrote on last edited by
          #4

          where is the object item is declared? and what exception the code throw?

          Help people,so poeple can help you.

          P 1 Reply Last reply
          0
          • A Ali Al Omairi Abu AlHassan

            where is the object item is declared? and what exception the code throw?

            Help people,so poeple can help you.

            P Offline
            P Offline
            Paul Harsent
            wrote on last edited by
            #5

            The object is been declared from the View when it is brought in from the model. I can access the item.price object from outside the

            , it might just be a basic miss understanding. value="50.00" I would like to be able to have value= <%item.price>% or something similar. Thanks

            <% foreach (var item in Model) { %>
            
                
                    
                      <%= Html.Encode(item.Id)%>
                    
                    
                        <%= Html.Encode(String.Format("{0:F}", item.Name))%>
                    
                    
                        <%= Html.Encode(item.Description) %>
                    
                    
                        <%= Html.Encode(String.Format("{0:F}", item.Price)) %>
                    
               
                      <%if (Roles.IsUserInRole("FullMember") == false)
                      {%>
                        
                    
            
                        
                        
            
                        
                        
            
                        
                        
            
                        
                        
            
                        
                        
            
                        
            
                        ![](https://www.paypal.com/en_US/i/scr/pixel.gif)
                               
                        
                    <%}
                      else
                      { %>
                      
                      <%=Html.ActionLink("Read", "ViewItem", "item", new {itemID = item.Id,itemName = item.Name, itemDescription = item.Description, itemFullArt = item.FullArt, itemPrice = item.Price }, nul
            
            A 1 Reply Last reply
            0
            • P Paul Harsent

              The object is been declared from the View when it is brought in from the model. I can access the item.price object from outside the

              , it might just be a basic miss understanding. value="50.00" I would like to be able to have value= <%item.price>% or something similar. Thanks

              <% foreach (var item in Model) { %>
              
                  
                      
                        <%= Html.Encode(item.Id)%>
                      
                      
                          <%= Html.Encode(String.Format("{0:F}", item.Name))%>
                      
                      
                          <%= Html.Encode(item.Description) %>
                      
                      
                          <%= Html.Encode(String.Format("{0:F}", item.Price)) %>
                      
                 
                        <%if (Roles.IsUserInRole("FullMember") == false)
                        {%>
                          
                      
              
                          
                          
              
                          
                          
              
                          
                          
              
                          
                          
              
                          
                          
              
                          
              
                          ![](https://www.paypal.com/en_US/i/scr/pixel.gif)
                                 
                          
                      <%}
                        else
                        { %>
                        
                        <%=Html.ActionLink("Read", "ViewItem", "item", new {itemID = item.Id,itemName = item.Name, itemDescription = item.Description, itemFullArt = item.FullArt, itemPrice = item.Price }, nul
              
              A Offline
              A Offline
              Ali Al Omairi Abu AlHassan
              wrote on last edited by
              #6

              Have you tried this

              <input type="hidden" name="amount" value="<%= item.price %>" />

              , this

              <input type="hidden" name="amount" value="<% item.price %>" />

              or none.

              Help people,so poeple can help you.

              1 Reply Last reply
              0
              • P Paul Harsent

                I have a form for which I want the price to resemble the current price of an object. But I cant add any C# into this form. Im building a paypal program using MVC.

                <%if (Roles.IsUserInRole("FullMember") == false)
                {%>

                I want to place

                <% item.price%>

                Into the value-"10.00" place. Is this possialbe and how do I go about doing this? Thanks

                S Offline
                S Offline
                Syed Zoheb Ali Sumair
                wrote on last edited by
                #7

                try this <input type="hidden" name="amount" value=<%:item.price%> you need to add after % : in your code :)

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups