bit long winded this one, so stick with me:
I'm trying to create a form that can go to one of 3 places, depending on
various elements. My form control looks like this:
<form runat="server" ID="myForm" method=POST>
so, first thing: how can I dynamically set the "Action" parameter? I
know that with <asp:HiddenField...for example, I have to do something
like this:
<% fieldID.Value = "stringContent" %>
<asp:HiddenField ID="fieldID"></asp:HiddenField>
so I'm guessing I can do the same kind of thing for the form control,
but "myForm.Action" doesn't appear to work.
I also tried
<% string myString = "here.aspx" %>
<form runat="server" ID="myForm" method=POST action="<%= myString %>">
but that didn't work either.
Here's the second part:
To get the value of the forms Action, I need to connect to a database,
so I setup a DataTable and grab the data. I figure I need to do this
outside of the <formtag, so that I can put the value into it's Action,
but I also want to be able to use that DataTable inside the form, but
I've found that anything I setup before the <form runat=serverline
isn't accessible within the form (such as the other fields from the
database for populating the form textboxes.
Can I set up a string, int, DataTable, etc outside the form that can
also be used inside it? If so, please please tell me how :)
Cheers
Kevin 4 2796
if you are using 2.0, you can set the postback url in a button. in version
one, you need to use cient script.
-- brue (sqlwork.com)
"Kevin Blount" <ke**********@LOLgmail.comwrote in message
news:u1**************@TK2MSFTNGP04.phx.gbl...
bit long winded this one, so stick with me:
I'm trying to create a form that can go to one of 3 places, depending on
various elements. My form control looks like this:
<form runat="server" ID="myForm" method=POST>
so, first thing: how can I dynamically set the "Action" parameter? I know
that with <asp:HiddenField...for example, I have to do something like
this:
<% fieldID.Value = "stringContent" %>
<asp:HiddenField ID="fieldID"></asp:HiddenField>
so I'm guessing I can do the same kind of thing for the form control, but
"myForm.Action" doesn't appear to work.
I also tried
<% string myString = "here.aspx" %>
<form runat="server" ID="myForm" method=POST action="<%= myString %>">
but that didn't work either.
Here's the second part:
To get the value of the forms Action, I need to connect to a database, so
I setup a DataTable and grab the data. I figure I need to do this outside
of the <formtag, so that I can put the value into it's Action, but I
also want to be able to use that DataTable inside the form, but I've found
that anything I setup before the <form runat=serverline isn't accessible
within the form (such as the other fields from the database for populating
the form textboxes.
Can I set up a string, int, DataTable, etc outside the form that can also
be used inside it? If so, please please tell me how :)
Cheers
Kevin
Bruce: Thanks for the reply. I'm not familiar this the postback url, but
I've done some quick research and found the following example:
<asp:button id="Button2"
text="Post value to another page"
postbackurl="Button.PostBackUrlPage2cs.aspx"
runat="Server">
</asp:button>
Quick question about this code:
Should I be adding a different button for each URL, or can I set this
dynamically in the same way as my asp:HiddenField example, e.g.
<%
if (blah)
{
Button2.Text = "go to myURL";
Button2.postbackurl = myURL;
}
else
{
Button2.Text = "go to myOtherURL";
Button2.postbackurl = myOtherURL
}
<asp:button id="Button2" runat="Server">
</asp:button>
and if so, should I use ".PostBackUrl", "PostBackURL", "postbackurl" or
doesn't it matter (which I doubt)?
Cheers
Kevin
bruce barker (sqlwork.com) wrote:
if you are using 2.0, you can set the postback url in a button. in version
one, you need to use cient script.
-- brue (sqlwork.com)
On Wed, 23 Aug 2006 15:42:36 -0500, Kevin Blount wrote:
bit long winded this one, so stick with me:
I'm trying to create a form that can go to one of 3 places, depending on
various elements. My form control looks like this:
Short answer is, you can't do it.
ASP.NET pages post back to themselves, otherwise there's no way for them to
handle control events.
The longer answer is that ASP.NET 2.0 introduced a way to do postback's to
another page with the button control, but that may not be what you're
looking for.
bruce barker (sqlwork.com) wrote:
if you are using 2.0, you can set the postback url in a button. in version
one, you need to use cient script.
-- brue (sqlwork.com)
"Kevin Blount" <ke**********@LOLgmail.comwrote in message
news:u1**************@TK2MSFTNGP04.phx.gbl...
>bit long winded this one, so stick with me:
I'm trying to create a form that can go to one of 3 places, depending on various elements. My form control looks like this:
<form runat="server" ID="myForm" method=POST>
so, first thing: how can I dynamically set the "Action" parameter? I know that with <asp:HiddenField...for example, I have to do something like this:
<% fieldID.Value = "stringContent" %> <asp:HiddenField ID="fieldID"></asp:HiddenField>
so I'm guessing I can do the same kind of thing for the form control, but "myForm.Action" doesn't appear to work.
I also tried
<% string myString = "here.aspx" %> <form runat="server" ID="myForm" method=POST action="<%= myString %>">
but that didn't work either.
Here's the second part: To get the value of the forms Action, I need to connect to a database, so I setup a DataTable and grab the data. I figure I need to do this outside of the <formtag, so that I can put the value into it's Action, but I also want to be able to use that DataTable inside the form, but I've found that anything I setup before the <form runat=serverline isn't accessible within the form (such as the other fields from the database for populating the form textboxes.
Can I set up a string, int, DataTable, etc outside the form that can also be used inside it? If so, please please tell me how :)
Cheers
Kevin
Bruce,
Thanks again for pointing me in the right direction. Now that I'm back
in the office I've been playing around with PostBackUrl, and I found
that I can dynamically set this, using the following:
<%
EventSubmit.Text = "this is the button text";
EventSubmit.PostBackUrl = "/us/seminars/index.aspx";
%>
<asp:Button ID="EventSubmit" runat="server"></asp:Button>
This will let me set the text based on the translated text from the
database, and also set the resulting URL based on the contents of the
form/page.
Many thanks for the help; I sincerely doubt I would have found this
option if let to my own devices (I'm having to use Dreamweaver for my
aspx pages, which has very limited .NET intelisense)
Kevin This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Michael |
last post by:
There seem to be two ways to include files on the server:
1. <!-- #include file="header.inc" -->
2. <script language="VBScript" runat="server" src="header.inc"></script>
What are the differences...
|
by: Hai Nguyen |
last post by:
Hi all
I have a several User Controls which require this tag: "<form
runat="server">. I tried to have all of these user user controls on the same
web page. It kept giving me an error :""A page...
|
by: Tim Mulholland |
last post by:
I have one page where i have some <div> tags set to be runat="server" (and
i've given them an id) and i can access them from the code-behind file just
fine.
I have another page where i've done...
|
by: Jaime Stuardo |
last post by:
Hi all...
Both controls are server side. The former has more properties. Both may have
associated events that are ran at server.
Which one are recommended to use? is performance an issue? in...
|
by: Jim in Arizona |
last post by:
Most of the asp.net learning I've done has been from books that were written
during the 1.0 framework. I didn't have a copy of visual studio when I
started reading them then I got a hold of VS 2005...
|
by: uto |
last post by:
<uc1:uc_pager ID="Uc_pager1" runat="server"
CurrentPage="<%=page%>"
PageCount="<%=pageCount%>"
PageSize="<%=pageSize%>"
/>
i'd like to input data into usercontrol when page loading
but this...
|
by: Tom |
last post by:
I need to use DynamicHoverStyle. I read that in order to do so, I must add a
<head runat="server" /> at the top of my UserCOntrol.
When I do this though, my DynamicMenuItemStyle items get...
|
by: mark4asp |
last post by:
<form runat="server"automatically adds <divtag to code contained
within. Is there a way to stop that?
Mixing block-level elements with inline-level elements messes up the
HTML becasuse that is...
|
by: Scott M. |
last post by:
Why do we need runat="server" on our <headtags?
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
|
by: WisdomUfot |
last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
|
by: Carina712 |
last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
|
by: BLUEPANDA |
last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
|
by: Rahul1995seven |
last post by:
Introduction:
In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
|
by: Johno34 |
last post by:
I have this click event on my form. It speaks to a Datasheet Subform
Private Sub Command260_Click()
Dim r As DAO.Recordset
Set r = Form_frmABCD.Form.RecordsetClone
r.MoveFirst
Do
If...
|
by: ezappsrUS |
last post by:
Hi,
I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
|
by: DizelArs |
last post by:
Hi all)
Faced with a problem, element.click() event doesn't work in Safari browser.
Tried various tricks like emulating touch event through a function:
let clickEvent = new Event('click', {...
| |