473,387 Members | 1,771 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to assign Action property to the Form

Hello,

In my application on the Webform I need to assign an action property to the
form in code, because the URL is a variable.

In MSDN there is an example - everything is simple:

Form1.Action=URL

However, this applies only to the Mobile controls. How can I do it in the
regular Webform?

I would appreciate your help.

Thank you,

--
Peter Afonin
Nov 18 '05 #1
6 1592
Peter,

You can emit javascript code assigning action property to the form from
server side:

Response.Write("<script language='Javascript'>");
Response.Write(String.Format("myForm.action={0}",m yUrl);
Response.Write("</script>");

This might not work since the document object model might not be built at
the loading time.
I think, the following should work:

Response.Write("<script language='Javascript'>");
Response.Write(String.Format("document.getElementB yId('myForm').action={0}",
myUrl);
Response.Write("</script>");

In any case, this should work always:

In the html view set <body onload="onLoad()"> and make onLoad() on fly as
Response.Write("<script language='Javascript'>");
Response.Write(String.Format("function onLoad(){myForm.action={0};}",myUrl);
Response.Write("</script>");

Eliyahu

"Peter Afonin" <pv*@speakeasy.net> wrote in message
news:uG**************@TK2MSFTNGP14.phx.gbl...
Hello,

In my application on the Webform I need to assign an action property to the form in code, because the URL is a variable.

In MSDN there is an example - everything is simple:

Form1.Action=URL

However, this applies only to the Mobile controls. How can I do it in the
regular Webform?

I would appreciate your help.

Thank you,

--
Peter Afonin

Nov 18 '05 #2
Thank you very much, Eliyahu. I'll give it a try.

Peter

"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:Ok*************@TK2MSFTNGP10.phx.gbl...
Peter,

You can emit javascript code assigning action property to the form from
server side:

Response.Write("<script language='Javascript'>");
Response.Write(String.Format("myForm.action={0}",m yUrl);
Response.Write("</script>");

This might not work since the document object model might not be built at
the loading time.
I think, the following should work:

Response.Write("<script language='Javascript'>");
Response.Write(String.Format("document.getElementB yId('myForm').action={0}", myUrl);
Response.Write("</script>");

In any case, this should work always:

In the html view set <body onload="onLoad()"> and make onLoad() on fly as
Response.Write("<script language='Javascript'>");
Response.Write(String.Format("function onLoad(){myForm.action={0};}",myUrl); Response.Write("</script>");

Eliyahu

"Peter Afonin" <pv*@speakeasy.net> wrote in message
news:uG**************@TK2MSFTNGP14.phx.gbl...
Hello,

In my application on the Webform I need to assign an action property to

the
form in code, because the URL is a variable.

In MSDN there is an example - everything is simple:

Form1.Action=URL

However, this applies only to the Mobile controls. How can I do it in the regular Webform?

I would appreciate your help.

Thank you,

--
Peter Afonin


Nov 18 '05 #3
You may wanna implement a Front Controller pattern on the server. My personal
opinion, that injecting a client code that would (potentially) expose your
inner logic to a client is a bad idea.

So, refer to Microsoft Enterprise Solution Patterns book (obtained online)
for implementation of the mentioned pattern (again, Front Controller).
Basically, the idea is to first, determine, what type of client you're
dealing with, and then using server.transfer() redirect the execution to a
more proper page/logic.

Hope this would be helpful for your work.

Andrew.

"Eliyahu Goldin" wrote:
Peter,

You can emit javascript code assigning action property to the form from
server side:

Response.Write("<script language='Javascript'>");
Response.Write(String.Format("myForm.action={0}",m yUrl);
Response.Write("</script>");

This might not work since the document object model might not be built at
the loading time.
I think, the following should work:

Response.Write("<script language='Javascript'>");
Response.Write(String.Format("document.getElementB yId('myForm').action={0}",
myUrl);
Response.Write("</script>");

In any case, this should work always:

In the html view set <body onload="onLoad()"> and make onLoad() on fly as
Response.Write("<script language='Javascript'>");
Response.Write(String.Format("function onLoad(){myForm.action={0};}",myUrl);
Response.Write("</script>");

Eliyahu

"Peter Afonin" <pv*@speakeasy.net> wrote in message
news:uG**************@TK2MSFTNGP14.phx.gbl...
Hello,

In my application on the Webform I need to assign an action property to

the
form in code, because the URL is a variable.

In MSDN there is an example - everything is simple:

Form1.Action=URL

However, this applies only to the Mobile controls. How can I do it in the
regular Webform?

I would appreciate your help.

Thank you,

--
Peter Afonin


Nov 18 '05 #4
Thank you, Andrew.

Peter

"Andrew_Revinsky" <An************@discussions.microsoft.com> wrote in
message news:88**********************************@microsof t.com...
You may wanna implement a Front Controller pattern on the server. My personal opinion, that injecting a client code that would (potentially) expose your
inner logic to a client is a bad idea.

So, refer to Microsoft Enterprise Solution Patterns book (obtained online)
for implementation of the mentioned pattern (again, Front Controller).
Basically, the idea is to first, determine, what type of client you're
dealing with, and then using server.transfer() redirect the execution to a
more proper page/logic.

Hope this would be helpful for your work.

Andrew.

"Eliyahu Goldin" wrote:
Peter,

You can emit javascript code assigning action property to the form from
server side:

Response.Write("<script language='Javascript'>");
Response.Write(String.Format("myForm.action={0}",m yUrl);
Response.Write("</script>");

This might not work since the document object model might not be built at the loading time.
I think, the following should work:

Response.Write("<script language='Javascript'>");
Response.Write(String.Format("document.getElementB yId('myForm').action={0}", myUrl);
Response.Write("</script>");

In any case, this should work always:

In the html view set <body onload="onLoad()"> and make onLoad() on fly as Response.Write("<script language='Javascript'>");
Response.Write(String.Format("function onLoad(){myForm.action={0};}",myUrl); Response.Write("</script>");

Eliyahu

"Peter Afonin" <pv*@speakeasy.net> wrote in message
news:uG**************@TK2MSFTNGP14.phx.gbl...
Hello,

In my application on the Webform I need to assign an action property to
the
form in code, because the URL is a variable.

In MSDN there is an example - everything is simple:

Form1.Action=URL

However, this applies only to the Mobile controls. How can I do it in

the regular Webform?

I would appreciate your help.

Thank you,

--
Peter Afonin


Nov 18 '05 #5
Hello Eliyahu,

Tried to use your last method, but noticed that in the aspx form there is no
method onLoad, so it didn't work.

I keep trying using other methods.

I wonder if there is a way to refer to the form directly from the code, just
like I can refer to the textbox or the other controls.

Thank you,

Peter

"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:Ok*************@TK2MSFTNGP10.phx.gbl...
Peter,

You can emit javascript code assigning action property to the form from
server side:

Response.Write("<script language='Javascript'>");
Response.Write(String.Format("myForm.action={0}",m yUrl);
Response.Write("</script>");

This might not work since the document object model might not be built at
the loading time.
I think, the following should work:

Response.Write("<script language='Javascript'>");
Response.Write(String.Format("document.getElementB yId('myForm').action={0}", myUrl);
Response.Write("</script>");

In any case, this should work always:

In the html view set <body onload="onLoad()"> and make onLoad() on fly as
Response.Write("<script language='Javascript'>");
Response.Write(String.Format("function onLoad(){myForm.action={0};}",myUrl); Response.Write("</script>");

Eliyahu

"Peter Afonin" <pv*@speakeasy.net> wrote in message
news:uG**************@TK2MSFTNGP14.phx.gbl...
Hello,

In my application on the Webform I need to assign an action property to

the
form in code, because the URL is a variable.

In MSDN there is an example - everything is simple:

Form1.Action=URL

However, this applies only to the Mobile controls. How can I do it in the regular Webform?

I would appreciate your help.

Thank you,

--
Peter Afonin


Nov 18 '05 #6
I'm sorry, it was a stupid remark - onLoad is a body method, not form. Still
doesn't work for some reason, I keep trying.

Peter

"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:Ok*************@TK2MSFTNGP10.phx.gbl...
Peter,

You can emit javascript code assigning action property to the form from
server side:

Response.Write("<script language='Javascript'>");
Response.Write(String.Format("myForm.action={0}",m yUrl);
Response.Write("</script>");

This might not work since the document object model might not be built at
the loading time.
I think, the following should work:

Response.Write("<script language='Javascript'>");
Response.Write(String.Format("document.getElementB yId('myForm').action={0}", myUrl);
Response.Write("</script>");

In any case, this should work always:

In the html view set <body onload="onLoad()"> and make onLoad() on fly as
Response.Write("<script language='Javascript'>");
Response.Write(String.Format("function onLoad(){myForm.action={0};}",myUrl); Response.Write("</script>");

Eliyahu

"Peter Afonin" <pv*@speakeasy.net> wrote in message
news:uG**************@TK2MSFTNGP14.phx.gbl...
Hello,

In my application on the Webform I need to assign an action property to

the
form in code, because the URL is a variable.

In MSDN there is an example - everything is simple:

Form1.Action=URL

However, this applies only to the Mobile controls. How can I do it in the regular Webform?

I would appreciate your help.

Thank you,

--
Peter Afonin


Nov 18 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Michael Brennan-White | last post by:
If I submit my for using a get action the resulting page loads . If I use a post action I get an error page saying "The page cannot be found". I am calling the originating page!!! This happens...
1
by: Shannon | last post by:
Hi, all -- this is a weird question that does not really have to do with javascript, but I used to spend a lot of time here, and am hoping someone might be able to help... I am trying to...
4
by: Bosconian | last post by:
I have created a form tool page that consists of several dropdowns which allows a user to drill down and select a desired document for viewing in an external window. I need to post the form data to...
3
by: shanmukhi | last post by:
hi all, i got a problem with struts. iam unable to find it. i have written an action class, form bean class and a jsp page on submitting form, request is going to action class but it is not...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.