Skip to content Skip to sidebar Skip to footer

What Happens To An "input" On "submit"? And How Can That Be Done By Asp.net?

Possible Duplicate: Read Post Data submitted to ASP.Net Form I have a google checkout 'buy now' button, and am trying to add dynamically created content to send when it's clicke

Solution 1:

The short, concise and usefull version:

Html:

<form id="__parent" action="..." method="post" runat="server">
    <input id="__child0" name="type"type="hidden" value="button" runat="server" />
    <input id="__child1" name="name"type="hidden" value="teh_button" runat="server" />
    <input id="__child2" name="value"type="hidden" value="Hello?" runat="server" />
</form>

tehfile.cs:

<%@ PageLanguage="C#"CodeFile="tehfile.cs"%>String
    _type = __child0.Value,
    _name = __child1.Value,
    _value     = __child2.Value,
    _element   =String.Format( 
        "<{0} {1}=\"{2}\" {3}=\"{4}\" {5}=\"{6}\" />", 
        "input", 
        "type", _type,
        "name", _name,
        "value", _value  );

Literal _lit = new Literal( );
_lit.Text= _element;

__parent.AddControl( _lit );

Solution 2:

To post that data to another server on the ASP.NET server-side, you are going to need to use something like the WebRequest class.

Solution 3:

Or also in order to post a form, you can use a remote post class like any of the ones here: Remote HTTP Post with C# , the answer by @BobbyShaftoe is the one i've used in many projects.

Solution 4:

Same question/POST here. I would have commented instead of answered, but seems this is a better/formatted way to get to bottom of it all:

In your comment to @MarcusHansson's answer:

I fail to see how this addresses the question of how to use the codebehind to send the information

You are mixing server side with client side submission methods.

If you want to submit using "code behind" you must implement server-to-server HTTP Post. In the context of Google Checkout, I've provided that link in your other post.

Your client side is using an HTML FORM which in, and of itself is how you "send the data". You can try all sorts of client-side submission processes, but at the end of the day, it is a client-side (Javascript) method.

What is "dynamic" about your buy now button? It's meant for a single item (at a time) purchase. Why can't you construct all the variables you need at the same time you create the button? What are you adding (that requires another redirect or postback)?

Post a Comment for "What Happens To An "input" On "submit"? And How Can That Be Done By Asp.net?"