Jump to content
  • Advertisement
Sign in to follow this  

Simple postback of values without clearing the page's values

This topic is 2089 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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">
        <title>Testing Stuff</title>
        <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>
                <br /><br />
                <input type="submit" id="submit" name="submit" value="Submit" />

And my server-side script

        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.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!