Jump to content

  • Log In with Google      Sign In   
  • Create Account

Simple postback of values without clearing the page's values


Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
No replies to this topic

#1   GDNet+   

6810
Like
0Likes
Like

Posted 25 January 2014 - 07:49 AM

Note: I've been using ASP.NET Webforms, so ViewState was my friend.

Note: Default.html and Default.cshtml are two different files/pages.

Basically, all I'm trying to do is take form values from a .html page, post them, and then go back to the original page without the values resetting.

Here's what I have so far:

My client-side script

    <!-- Default.html -->
    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Testing Stuff</title>
    </head>
    <body>
        <form id="mainpage" action="Default.cshtml" method="post">
            <div style="clear:both;" id="dbInput">
                <label for="linedesc">Description:</label>&nbsp;
                <input type="text" id="linedesc" name="linedesc" />
                <br /><br />
                <input id="fruits" name="options1" value="fruits" type="radio" />
                <label for="fruits">Fruits</label>&nbsp;
                <input id="candies" name="options1" value="candies" type="radio" />
                <label for="candies">Candies</label>&nbsp;
                <input id="snacks" name="options1" value="snacks" type="radio" />
                <label for="snacks">Snacks</label>
                <br /><br />
                <label for="options2">Choose beverage:</label>&nbsp;
                 <select id="options2" name="options2">
                    <option value="Coca-Cola">Coca-Cola</option>
                    <option value="Sprite">Sprite</option>
                    <option value="Root Beer">Root Beer</option>
                    <option value="Orange Juice">Orange Juice</option>
                </select>
                <br /><br />
                <input type="submit" id="submit" name="submit" value="Submit" />
            </div>
        </form>
    </body>
    </html>


And my server-side script
 

    //Default.cshtml
    @{
        var linedesc = Request.Form["linedesc"];
        var food = Request.Form["options1"];
        var drinks = Request.Form["options2"];
        
        // Go back to Default.html and keep values selected, ie. values don't reset
        var blah = "hi";
    }


All I want to do is simple, no bells, no whistles, postback and return. I'm just missing that last piece.


External Articulation of Concepts Materializes Innate Knowledge of One's Craft and Science
 
Beginner in Game Development? Read here. And read here.
 
Super Mario Bros clone tutorial written in XNA 4.0 [MonoGame, ANX, and MonoXNA] by Scott Haley
 
If you have found any of the posts helpful, please show your appreciation by clicking the up arrow on those posts Posted Image
 
Spoiler




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.