[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.webcontrols

Programmatically Submit in asp.net?

Joe

2/11/2004 11:41:00 PM

Is the only way to programatically submit a html form to use vbscript or javascript? ie:

<script
function __doPostBack(eventTarget, eventArgument)
var theform = document.WebForm3
theform.__EVENTTARGET.value = eventTarget
theform.__EVENTARGUMENT.value = eventArgument
theform.submit()


</script
In pure C#...

#1 Is there no object to do this

#2 Can you programmatically (except for above) add items to the form collection / params collection

j


11 Answers

CMA

2/12/2004 3:44:00 AM

0

i can only provide an answer to the first one.
since C# can use only in server side, u dont have a way to use it to submit
a form...

CMA


"Joe" <joedirt@datahook.com> wrote in message
news:057C6FAE-901D-4244-B866-6F07C2915019@microsoft.com...
> Is the only way to programatically submit a html form to use vbscript or
javascript? ie:
>
> <script>
> function __doPostBack(eventTarget, eventArgument) {
> var theform = document.WebForm3;
> theform.__EVENTTARGET.value = eventTarget;
> theform.__EVENTARGUMENT.value = eventArgument;
> theform.submit();
> }
>
> </script>
> In pure C#....
>
> #1 Is there no object to do this?
>
> #2 Can you programmatically (except for above) add items to the form
collection / params collection ?
>
> jz
>
>


v-jetan

2/12/2004 10:42:00 AM

0


Hi joedirt,

Thank you for posting in the community!

Based on my understanding, you have 2 questions about the form submit.

=================================================
Yes, to submit a form programatically, you must use Form.submit() method.

For your first question, I think you must have some concept
misunderstanding of Asp.net.

In asp.net, there are 2 types of script code: server side(With runat=server
attribute) and client side.

The server side code, it will execute at server side, and you can use C#,
VB, jscript and other languages to write. It is compile execute.
While the client side script will execute at client side, and you only can
use Javascript(or Jscript) and VBscript. It is interpret execute.

To submit a form, normally, you mean submit the entire form from the client
side to the server side, so it is client script. So you can not use C# to
write code.(The client script engine can not recognize the C# code)

For your #2, you can add programmatically add html element data into the
post that is posted back to the server side.(Normal ASP way)

Again, I will clarify the mechanism for you:
Asp.net introduces the concept of Server side web control. The webcontrol
encapsulates some of the behaviors of the html element. All the webcontrol
use the Form.submit() method to postback to the server side. It uses 2
hiden fields: __EVENTTARGET and __EVENTARGUMENT to store the data.

So it makes no sense for you to add the data into these 2 fields, because
at the server side, there are no server side objects to associate with your
data!

But you can programmatically add the data into the form data that is posted
back to the server side. Then at server side, you can use HttpResponse.Form
to access the added data.

Do like this:

At client side:

<INPUT type="button" value="Button" onclick="addformdata()">

<script language="javascript">
function addformdata()
{
var oNewNode = document.createElement("INPUT");
document.Form1.appendChild(oNewNode);
oNewNode.type="text";
oNewNode.name="addeditem";
oNewNode.value="abcdef";
document.Form1.submit();
}
</script>

At server side, you can write the got data into client side:

private void Page_Load(object sender, System.EventArgs e)
{
this.Response.Write(this.Request.Form["addeditem"]);
}

===============================================
Please apply my suggestion above and let me know if it helps resolve your
problem.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.
Have a nice day!!

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Joe

2/12/2004 11:06:00 PM

0

Jeff, Thanks, that is what I thought. It is just frustrating to have to post, post, post. It is HTML/web standard I know. It would be a nice thought to let us put any object on the post event. ie: Let the browser/client send an object as one of the things on the form collection, opening up the forms collection to all objects.

v-jetan

2/13/2004 2:34:00 AM

0


Hi joedirt,

Thanks very much for your feedback.

Ok, you already know that Asp.net should use the PostBack to work. But I
want to correct you that this is not the HTML/web standard, this is the
mechanism of Asp.net.(Even not the feature of old Asp).

As you stated, you want to send OBJECT from the browser/client in the Form
Collection to the server side. Can you show me the exactly meanning of
"OBJECT"?
Because your "OBJECT" is at client side, I think it is not a server object
of Asp.net class instance. I think it means the client side html element.

Also, what is the exactly meanning of "Form Collection"? Does it mean the
server side web controls collection? If "Form Collection" does mean the
server side web control collection, Yes, you can not add customized client
side element into this "Form Collection", because the collection is
maintained at server side, you can not add into it from the client side.
I think you mean all the element data collection that is posted back to the
server side.

If "OBJECT" means the client side html element and "Form Collection" mean
all the element data collection that is posted back to the server side, I
think the javascript sample I provide you in orignal reply shows you how to
add textbox "OBJECT" into "Form Collection". And also, you can opening up
the forms collection to all objects.

If I fully misunderstand your meanning, please feel free to tell me, then I
think you need to explain some of these words for me:
1). form collection
2). object
3). HTML/web standard

With clearing the meanning of these words, I think I can fully understand
you.

Cheers!

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

v-jetan

2/17/2004 1:09:00 AM

0


Hi joedirt,

Does my reply make sense to you?

If you have anything unclear, please feel free to tell me, I will help you.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Deirdre Sholto Douglas

7/26/2009 12:30:00 PM

0

Malcolm wrote:

> Your response appears to be entirely predictable

Her post is entirely predictable also, Malcolm...
you need to observe the dynamic between them
a bit longer before you decide she's the victim
and he's the aggressor. Nilita, candidly, is
no better than Fred, she's just a bit sneakier
about how she presents it.

Deirdre


________________
Abort? Retry? Wing it?

Malcolm

7/26/2009 2:23:00 PM

0


In article <7d30i2F27h9beU1@mid.individual.net>, Deirdre Sholto Douglas
<finch.enteract@sbcglobal.net> writes
>Malcolm wrote:
>
>> Your response appears to be entirely predictable
>
>Her post is entirely predictable also, Malcolm...
>you need to observe the dynamic between them
>a bit longer before you decide she's the victim
>and he's the aggressor. Nilita, candidly, is
>no better than Fred, she's just a bit sneakier
>about how she presents it.
>
I've seen the interplay (if that's the right word!) between the two of
them. At the moment, though, it has only been Fred who has attempted to
attack me because he didn't realise in time that I knew a lot more than
he did about a subject which I happen to have worked on professionally
for a great many years :-)

His comprehension skills leave a lot to be desired, too. It's always
difficult discussing something with someone who has difficulty
understanding the written word. Did you see him accuse me of coming back
to have the last word when I had told him he could have it? What he
completely failed to comprehend was that I wasn't addressing him any
longer but someone else.

--
Malcolm

La N

7/26/2009 3:49:00 PM

0


"Malcolm" <Malcolm@indaal.demon.co.uk> wrote in message
news:G0DgIQrxfCbKFwJL@indaal.demon.co.uk...
>
> In article <fJSam.36566$Db2.4282@edtnps83>, La N
> <nilita2004NOSPAM@yahoo.com> writes
>> Now
>>howzabout spending time answering some of my bona fide biology fans
>>questions ... :)
>>
>>My query to you about the psychobiology of abandoned by children allegedly
>>raised in the wild was "en buena onda" ( in good faith) WRT the
>>nature/nurture question. Please do pay attention to us bona fides .. ;)
>>
> Indeed I will, and apologies for not getting back to you sooner.
>
> My own belief is that the animals raising children are relying entirely on
> instinct. There are plenty of examples of species of animals or birds
> rearing the young of other species of animals or birds. It is almost
> always a matter of chance whether they are accepted by the foster parent -
> having their own young at the same stage of growth, having just lost a
> young and therefore "adopting" another young not its own, being "adopted
> by" a straying or orphan young and not rejecting it, etc.
>

Thank you. I have long found the topic of interspecies rear quite
fascinating and terminally cute when it comes to videos, photos, and such.
A few years ago a big to do in my neck of the woods of a mother cat nursing
a litter of baby mice, which, of course, is contrary to ? instinct.

- nilita


Malcolm

7/26/2009 3:56:00 PM

0


In article <kV_am.36589$Db2.8266@edtnps83>, La N
<nilita2004NOSPAM@yahoo.com> writes
>
>"Malcolm" <Malcolm@indaal.demon.co.uk> wrote in message
>news:G0DgIQrxfCbKFwJL@indaal.demon.co.uk...
>>
>> In article <fJSam.36566$Db2.4282@edtnps83>, La N
>> <nilita2004NOSPAM@yahoo.com> writes
> >> Now
>>>howzabout spending time answering some of my bona fide biology fans
>>>questions ... :)
>>>
>>>My query to you about the psychobiology of abandoned by children allegedly
>>>raised in the wild was "en buena onda" ( in good faith) WRT the
>>>nature/nurture question. Please do pay attention to us bona fides .. ;)
>>>
>> Indeed I will, and apologies for not getting back to you sooner.
>>
>> My own belief is that the animals raising children are relying entirely on
>> instinct. There are plenty of examples of species of animals or birds
>> rearing the young of other species of animals or birds. It is almost
>> always a matter of chance whether they are accepted by the foster parent -
>> having their own young at the same stage of growth, having just lost a
>> young and therefore "adopting" another young not its own, being "adopted
>> by" a straying or orphan young and not rejecting it, etc.
>>
>
>Thank you. I have long found the topic of interspecies rear quite
>fascinating and terminally cute when it comes to videos, photos, and such.
>A few years ago a big to do in my neck of the woods of a mother cat nursing
>a litter of baby mice, which, of course, is contrary to ? instinct.
>
Contrary to the hunting instinct perhaps, but not, presumably, in this
case necessarily contrary to the maternal instinct.

--
Malcolm

La N

7/26/2009 3:57:00 PM

0


"Malcolm" <Malcolm@indaal.demon.co.uk> wrote in message
news:V2$EIPyBbGbKFwK2@indaal.demon.co.uk...
>
> In article <7d30i2F27h9beU1@mid.individual.net>, Deirdre Sholto Douglas
> <finch.enteract@sbcglobal.net> writes
>>Malcolm wrote:
>>
>>> Your response appears to be entirely predictable
>>
>>Her post is entirely predictable also, Malcolm...
>>you need to observe the dynamic between them
>>a bit longer before you decide she's the victim
>>and he's the aggressor. Nilita, candidly, is
>>no better than Fred, she's just a bit sneakier
>>about how she presents it.


>>
> I've seen the interplay (if that's the right word!) between the two of
> them. At the moment, though, it has only been Fred who has attempted to
> attack me because he didn't realise in time that I knew a lot more than he
> did about a subject which I happen to have worked on professionally for a
> great many years :-)
>
> His comprehension skills leave a lot to be desired, too. It's always
> difficult discussing something with someone who has difficulty
> understanding the written word. Did you see him accuse me of coming back
> to have the last word when I had told him he could have it? What he
> completely failed to comprehend was that I wasn't addressing him any
> longer but someone else.
>

But ... but ... it's all *my* fault, Malcolm, don't you see ... ;)

- nilita