Results 1 to 4 of 4

Thread: ASP.NET + html form problem.. (GCheckout)

  1. #1
    Theoretical Element Spud1's Avatar
    Join Date
    Jul 2003
    Location
    North West
    Posts
    7,508
    Thanks
    336
    Thanked
    320 times in 255 posts
    • Spud1's system
      • Motherboard:
      • Gigabyte Aorus Master
      • CPU:
      • 9900k
      • Memory:
      • 16GB GSkill Trident Z
      • Storage:
      • Lots.
      • Graphics card(s):
      • RTX3090
      • PSU:
      • 750w
      • Case:
      • BeQuiet Dark Base Pro rev.2
      • Operating System:
      • Windows 10
      • Monitor(s):
      • Asus PG35VQ
      • Internet:
      • 910/100mb Fibre

    ASP.NET + html form problem.. (GCheckout)

    Having a small problem with trying to integrate google checkout into a current ASP.NET website.

    It seemed such a simple task at the start - either use the .NET API for google checkout (which I can't easily do, will explain) or a bog standard html form with hidden fields and a submit button. Its being a pain though as you may expect.

    I'll briefly explain the page and why I can't use the .NET api first, then get to the real problem. The page as currently designed supports multiple views - eg 'Please Pay' 'You have Already Paid' and 'You have been deleted'. This is done by checking the state passed to the page on load, followed by some processing before control is passed to a 'getHTML()' method which generates and outputs the correct HTML via a literal. This is all done in a C# codebehind file, with the aspx file only contining an <asp:literal /> tag. Its a nice, flexible structure which works well..or did until now

    My preferred method of adding Google checkout support would be to simple add an asp:button or which would fire a 'payGoogleCheckout()' method on the server, create + sign the XML file and send it to google, finally redirecting the client to googles server. The problem I have here is that (unless anyone knows how) you can't add asp.net controls directly through a literal control - that is I can't add <asp:Button .. /> to the literal and expect a button to appear - it just doesn't. There are possibly ways around this by using a html button with its onClick set to a javascript function which can do the job, but thats very dirty and not what I want to be doing.

    A much simpler way I figured would be to just use a HTML form, as shown by Google on their website. Problem is it doesnt work, and in fact, no forms seem to work on this page. All they do is simply postback to the same page - totally ignoring the action. Eg if my page is called 'Games.aspx' and I want to post to 'Google.aspx', I would do something like:

    <form action="Google.aspx' method="Post" > <input type="Submit" ..etc /> </form>

    and I would expect it to go to Google.aspx - but it just sits on Games.aspx.

    If I can get this figured out via forms I'll be happy, but even better if someone knows a better way round the API problem..that doesn't involve me re-designing the whole site hah!.

    After typing this out I think its something to do with the auto-postbacks for this site, so i'm going to see if theres anything there that could be causing a problem..but any ideas/suggestions would be nice

  2. #2
    Large Member
    Join Date
    Apr 2004
    Posts
    3,720
    Thanks
    47
    Thanked
    99 times in 64 posts

    Re: ASP.NET + html form problem.. (GCheckout)

    You shouldnt really use a form anyway as it will most likely be nested inside the ASP.NET form which (as you probably know) makes it invalid HTML.

    Don't know if you can but your, quite simply easiest bet, is to change the literal to a label which (crazily) allows nested controls. Can you live with it all being wrapped inside a span!
    To err is human. To really foul things up ... you need a computer.

  3. Received thanks from:

    Spud1 (05-10-2007)

  4. #3
    Flower Child stytagm's Avatar
    Join Date
    Aug 2004
    Location
    London
    Posts
    754
    Thanks
    47
    Thanked
    23 times in 18 posts

    Re: ASP.NET + html form problem.. (GCheckout)

    Is it .Net 1.1? IIRC it's an annoying "quirk" that you can't have more than one form on a page, which means as mentioned before, you can only have the one .Net form. I think that they've fixed it in Asp.Net 2 or 3, but that's not much help.

    Having said that, I'd argue against your use of the asp literal. the whole point of separate aspx and code behind is to separate the html from the c# (or vb), and you're mingling them back together by generating html in the code behind.

    Assuming you're using 1.1, Why not get rid of your single literal, and put your three views (please pay etc) in separate divs in the aspx page. Add an ID tag and Runat="server" and in the code behind declare them as HtmlControls, this will allow you to turn the whole div on and off in the code behind, (those turned off will not even be sent to the browser). Then could you use the API?

    so in aspx page:
    Code:
    <snip>
    	<div id="divPleasePay" Runat="server" Visible="False">
    		<!-- Your stuff goes here -->
    	</div>
    </snip>
    In the code behind (C# in this case):
    Code:
    protected System.Web.UI.HtmlControls.HtmlControl divPleasePay;
    
    //snip
    	if (yourCondition)
    	{
    		divPleasePay.Visible = true;
    	}
    If you're using .Net 2.0, you can use <asp: panel> which resolves to a div when it's rendered (asp: panels are a bit iffy in .net 1.1 on browsers other than IE, but that's a different issue for another day)

    Surely the reason Google provide an .net Api is to work around the .Net form issues?
    They told me I was gullible ... and I believed them.

  5. Received thanks from:

    Spud1 (05-10-2007)

  6. #4
    Theoretical Element Spud1's Avatar
    Join Date
    Jul 2003
    Location
    North West
    Posts
    7,508
    Thanks
    336
    Thanked
    320 times in 255 posts
    • Spud1's system
      • Motherboard:
      • Gigabyte Aorus Master
      • CPU:
      • 9900k
      • Memory:
      • 16GB GSkill Trident Z
      • Storage:
      • Lots.
      • Graphics card(s):
      • RTX3090
      • PSU:
      • 750w
      • Case:
      • BeQuiet Dark Base Pro rev.2
      • Operating System:
      • Windows 10
      • Monitor(s):
      • Asus PG35VQ
      • Internet:
      • 910/100mb Fibre

    Re: ASP.NET + html form problem.. (GCheckout)

    Sorry I havn't updated this thread in a while, not had chance to look at this again..been one of those weeks hah.

    I'm using .NET 2.0 for this project, so its possible that the form bug is fixed in .net 3, not 2..but either way I think your right and that I should be using the API and not a standard html form for this..it allows for tighter integration with the store when we get round to it

    I think the best bet is to redesign the page a little as you both say, was just trying to avoid doing it really =) Thanks for the advice/suggestions

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. RAM problem
    By MML in forum PC Hardware and Components
    Replies: 12
    Last Post: 29-09-2006, 04:33 PM
  2. php - opening file to html form?
    By Ramedge in forum Software
    Replies: 11
    Last Post: 10-10-2005, 10:24 AM
  3. Me Again, HTML Form Question This Time
    By Vini in forum Software
    Replies: 19
    Last Post: 05-10-2005, 10:57 AM
  4. Replies: 4
    Last Post: 11-06-2004, 07:39 PM
  5. ASP HTML Form Advice
    By Angus in forum Software
    Replies: 3
    Last Post: 01-04-2004, 02:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •