[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 523
  • Last Modified:

ASP.NET Post Data

I have a feeling that I am not going to be able to explain myself very well on this issue.  Please forgive my .net ignorance. A few years ago, I created an interface for a database of tax records.  Here's the link to this interface:
http://www.murfreesborotn.gov/search.aspx

Please use the search so you'll be familiar with the pages I'll refer to later in this post.

The two pages I'm concerned with in this question are search.aspx and taxrecords.aspx.  I will need help with totals.aspx too, but I would like to split that into a different post.  

When you use the search, you'll notice that I passed all of my variables through the URL.  This worked well for a while, but now I have a need to pass my information in a "POST" like method.  Pretty much, I need to remove the variable info from the URL, but I still need to pass it from page to page.  

I tried to accomplish this using the html method of:

<form runat=server method=post action=taxrecords.aspx>

I know that method would work on a "normal" site, but we use Ektron as our CMS, and i get an error message about the page having two forms when I use it.  

I have attached the two pages I've mentioned.  How would I go about converting these pages to use POST instead of the method that I'm using now?  Thanks for reading.  Please let me know if I need to explain myself any further.  


search.aspx
taxrecords.aspx
0
thedeal56
Asked:
thedeal56
  • 13
  • 9
1 Solution
 
vbwizardryCommented:
are you changing form method in your master page or do you add a new form. If you are adding a new form you cant do that. Multiple server forms are not supported by regular asp.net.
0
 
thedeal56Author Commented:
Is there a way to send data in a post style without using a form? Like something I could do programmatic-ally?  
0
 
vbwizardryCommented:
yes...kind of...
You can, in your search.aspx load event handler, set form method to post as in.
        protected void Page_Load(object sender, EventArgs e)
        {
            Form.Method = "post";
        }

Open in new window

0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
thedeal56Author Commented:
is that a way around the two form ordeal?
0
 
vbwizardryCommented:
yes
0
 
vbwizardryCommented:
as long as you are not trying to add another form above should work.
0
 
vbwizardryCommented:
Question:
Why don't you set form in your MasterPage2 to use post method by default? Why did you change it to get?
0
 
thedeal56Author Commented:
Well, the master form was set to get by the content manager, Ektron.  On the pages that i'm talking about in this post, there was never a real form tag that was handling any of the data transfer.  I was just using a redirect in VB.net like this:
Protected Sub test_click(ByVal sender As Object, ByVal e As ImageClickEventArgs) Handles test.Click

                Response.Redirect("taxrecords.aspx?ekmenu=112&name=" + name.Text + "&address=" + address.Text + "&ctlmap=" + ctlmap.Text + "&group=" + group.Text + "&parcel=" + parcel.Text + "&propid=" + propid.Text + "&specint=" + specint.Text + "&billyear=" + billyear.Text + "&billnumber=" + billnumber.Text + "&Account=" + Account.Text )

            End Sub

Open in new window

0
 
vbwizardryCommented:
the form tag most likely located in MasterPage2. If you are using a Response.Redirect you might as well use html tags instead of asp control's. Also in page load event you can set the location of the form post/get method. That way you will not need to redirect. Look at HtmlForm class. You can set Action, Method and Target on the form.
0
 
vbwizardryCommented:
also you would have to change
asp:QueryStringParameter to asp:FormParameter in taxrecords.aspx
0
 
thedeal56Author Commented:
Good deal.  I'll look in to this tonight.  I really appreciate you helping me on this.
0
 
thedeal56Author Commented:
I had a chance to look at this last night, but I'm still unclear on how to make this work.  Here are the steps I took.

Remove the test_click Sub
Created a form with post method on search.aspx but did not add runat=server
Changed my image button info a form submit button
Changed asp:QueryStringParameter to asp:FormParameter in taxrecords.aspx

When I did this, the form never actually submitted to the taxrecords.aspx page.  Instead, the page flashed and stayed on search.aspx.

0
 
vbwizardryCommented:
Remove the test_click Sub
add this to the page
<script runat="server">
	Sub Page_Load
		if Not Page.IsPostBack then
			Form.Method = "post"
			Form.Action = "taxrecords.aspx"
		end if
	End Sub
</script>

Open in new window


Change asp:TextBox to regular html control [http://www.w3schools.com/html/html_forms.asp]

Do not created form with post method on search.aspx

Changed my image button info a form submit button [you don't have to do it]

Changed asp:QueryStringParameter to asp:FormParameter in taxrecords.aspx

0
 
thedeal56Author Commented:
Ah, I'm starting to see what you're saying now.  When you say to change the textbox to a regular html control, this is what you mean, right?

Take this:
 <asp:TextBox runat="server" ID="billnumber" size="8" maxlength=10 TextMode="SingleLine"></asp:TextBox>

Change to this:
<input runat="server" name="billnumber" size="8" maxlength=10></input>

Also, When I added the script from your prior post, I came across this error message:
BC30456: 'Action' is not a member of 'System.Web.UI.HtmlControls.HtmlForm'.
0
 
vbwizardryCommented:
do not add [runat="server"] simply use
<input type="text" name="billnumber" />

Open in new window

0
 
thedeal56Author Commented:
Good deal.  Will that take care of this too?
BC30456: 'Action' is not a member of 'System.Web.UI.HtmlControls.HtmlForm'.

I saw somewhere that this was a .net version issue.  Have you ever ran across that error?
0
 
thedeal56Author Commented:
I got .net 3.5 SP1, and that fixed the BC30456 error.  Now I am getting a sql timeout error when I submit the form.  Do I need to change anything else in this section?
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ProptaxConnectionString %>"
            SelectCommand="sp_TaxRec" CancelSelectOnNullParameter="False" SelectCommandType="StoredProcedure">
            <SelectParameters>
                <asp:FormParameter Name="name1" QueryStringField="name" ConvertEmptyStringToNull="False" />
                <asp:FormParameter ConvertEmptyStringToNull="False" Name="property_add" QueryStringField="address" />
                <asp:FormParameter Name="ctlmap" QueryStringField="ctlmap" />
                <asp:FormParameter Name="bill_group" QueryStringField="group" />
                <asp:FormParameter Name="bill_parcel" QueryStringField="parcel" />
                <asp:FormParameter Name="propertyid" QueryStringField="propid" />
                <asp:FormParameter Name="special" QueryStringField="specint" />
                <asp:FormParameter Name="bill_year" QueryStringField="billyear" />
                <asp:FormParameter Name="bill_no" QueryStringField="billnumber" />
                <asp:FormParameter Name="account" QueryStringField="account" />
            </SelectParameters>
        </asp:SqlDataSource>

Open in new window

0
 
thedeal56Author Commented:
I made a slight change to this, but it's still timing out
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ProptaxConnectionString %>"
            SelectCommand="sp_TaxRec" CancelSelectOnNullParameter="False" SelectCommandType="StoredProcedure">
            <SelectParameters>
                <asp:FormParameter Name="name1" FormField="name" ConvertEmptyStringToNull="False" />
                <asp:FormParameter ConvertEmptyStringToNull="False" Name="property_add" FormField="address" />
                <asp:FormParameter Name="ctlmap" FormField="ctlmap" />
                <asp:FormParameter Name="bill_group" FormField="group" />
                <asp:FormParameter Name="bill_parcel" FormField="parcel" />
                <asp:FormParameter Name="propertyid" FormField="propid" />
                <asp:FormParameter Name="special" FormField="specint" />
                <asp:FormParameter Name="bill_year" FormField="billyear" />
                <asp:FormParameter Name="bill_no" FormField="billnumber" />
                <asp:FormParameter Name="account" FormField="account" />
            </SelectParameters>
        </asp:SqlDataSource>

Open in new window

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ProptaxConnectionString %>"
            SelectCommand="sp_TaxRec" CancelSelectOnNullParameter="False" SelectCommandType="StoredProcedure">
            <SelectParameters>
                <asp:FormParameter Name="name1" FormField="name" ConvertEmptyStringToNull="False" />
                <asp:FormParameter ConvertEmptyStringToNull="False" Name="property_add" FormField="address" />
                <asp:FormParameter Name="ctlmap" FormField="ctlmap" />
                <asp:FormParameter Name="bill_group" FormField="group" />
                <asp:FormParameter Name="bill_parcel" FormField="parcel" />
                <asp:FormParameter Name="propertyid" FormField="propid" />
                <asp:FormParameter Name="special" FormField="specint" />
                <asp:FormParameter Name="bill_year" FormField="billyear" />
                <asp:FormParameter Name="bill_no" FormField="billnumber" />
                <asp:FormParameter Name="account" FormField="account" />
            </SelectParameters>
        </asp:SqlDataSource>

Open in new window

0
 
thedeal56Author Commented:
sorry for the double code snippets.  I just meant to post one.
0
 
thedeal56Author Commented:
ok, nevermind all that.  It looks to be working now! Thanks again for all your help.  I still need help posting from taxrecords.aspx in to totals.aspx.  I'll make a new question, and I'll post back here when I do.
0
 
thedeal56Author Commented:
Awesome!
0
 
thedeal56Author Commented:
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 13
  • 9
Tackle projects and never again get stuck behind a technical roadblock.
Join Now