[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

ASP.NET Post Data

Posted on 2011-03-01
22
Medium Priority
?
519 Views
Last Modified: 2012-05-11
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
Comment
Question by:thedeal56
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 13
  • 9
22 Comments
 
LVL 7

Expert Comment

by:vbwizardry
ID: 35010741
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
 

Author Comment

by:thedeal56
ID: 35010803
Is there a way to send data in a post style without using a form? Like something I could do programmatic-ally?  
0
 
LVL 7

Expert Comment

by:vbwizardry
ID: 35011026
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:thedeal56
ID: 35011040
is that a way around the two form ordeal?
0
 
LVL 7

Expert Comment

by:vbwizardry
ID: 35011047
yes
0
 
LVL 7

Expert Comment

by:vbwizardry
ID: 35011054
as long as you are not trying to add another form above should work.
0
 
LVL 7

Expert Comment

by:vbwizardry
ID: 35011075
Question:
Why don't you set form in your MasterPage2 to use post method by default? Why did you change it to get?
0
 

Author Comment

by:thedeal56
ID: 35011123
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
 
LVL 7

Expert Comment

by:vbwizardry
ID: 35011209
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
 
LVL 7

Expert Comment

by:vbwizardry
ID: 35011438
also you would have to change
asp:QueryStringParameter to asp:FormParameter in taxrecords.aspx
0
 

Author Comment

by:thedeal56
ID: 35011559
Good deal.  I'll look in to this tonight.  I really appreciate you helping me on this.
0
 

Author Comment

by:thedeal56
ID: 35019046
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
 
LVL 7

Accepted Solution

by:
vbwizardry earned 2000 total points
ID: 35020060
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
 

Author Comment

by:thedeal56
ID: 35020500
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
 
LVL 7

Expert Comment

by:vbwizardry
ID: 35020777
do not add [runat="server"] simply use
<input type="text" name="billnumber" />

Open in new window

0
 

Author Comment

by:thedeal56
ID: 35020979
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
 

Author Comment

by:thedeal56
ID: 35022423
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
 

Author Comment

by:thedeal56
ID: 35022508
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
 

Author Comment

by:thedeal56
ID: 35022511
sorry for the double code snippets.  I just meant to post one.
0
 

Author Comment

by:thedeal56
ID: 35022576
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
 

Author Closing Comment

by:thedeal56
ID: 35022581
Awesome!
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question