Advice on querystring and template form

Results 1 to 2 of 2

Thread: Advice on querystring and template form

  1. #1
    Join Date
    Dec 1969

    Default Advice on querystring and template form

    I need some advice on how to handle and administritive product page. If I explain how I used to code it in ASP I can then present the problem I have just found with .net and where I could do with some guidance to best get around it:<BR><BR>I had a list of products that I am able to click edit on and it takes me to a seperate page, product.asp(x), to edit the details. I use the same form for creating a new product aswell as for editing, what I used to do was pass a variable along the QS such as action=new, from the list page, and the code would present a blank form. The QS &#039;action&#039; variable&#039; would be copied into the QS value in the form&#039;s action property eg:product.asp?action=new, when the user clicked submit the value was read in and an insert statement was run and the action value was changed to &#039;edit&#039;. <BR><BR>When I wanted to edit a product I would pass the id and the action=edit along the QS, the id was detected and data loaded into the form whos action was set to product.asp?action=edit&id=2, you get what happens next. <BR><BR>I&#039;m trying to code the same type of page in .net, I have all my code ready but last night realised that with the form posting back to itself I cant amend the querystring data, or can I? I would like to use the same form for the two tasks can you recommend a better way of me doing this or do I have it wrong?<BR>Is there a web control for the htmlhidden input tag because I thought to read the values into that, it is just it was always a lot cleaner on the code to read the value in from the same place.<BR><BR>TIA<BR><BR>Lloyd

  2. #2
    Join Date
    Dec 1969

    Default I would have thought so

    I dont think there&#039;s a problem doing what you&#039;re suggesting but the process may have to be changed a little, firstly I would build the form as you suggested and assign the values to it during the page load (for instance by calling a function).<BR><BR>If there is a value in the QS then the function will complete the fields, if not it will exit. One way (even if it is long winded is to set a hidden value that can be referenced later, ie<BR><BR>if value in QS then set textbox value = QS value<BR>getFormValues()<BR><BR>getFormValues could first check for a value in that textbox, if none exit, the last thing in your update statement would be to set the value of the textbox, as ASP.NET should hold states this should show in the code.<BR><BR>As for your "hidden" box there are a couple of options, the first is to set Visible="False" in the textbox and another is to use a label programatically set its value in the code.<BR><BR>Sorry to ramble, if you don&#039;t understand let me know and I&#039;ll try and draw up some example code for you.<BR><BR>Tim

Posting Permissions

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