__doPostBack code block not being generated by asp.net page

E

E

I have 2 aspx pages... neither of which do anything out of the ordinary.

One of the pages automatically generates this block of code when viewed at
the client:
------------------------------------------------------------
<form name="webfrmForm" method="post" action="pokedex.aspx" id="webfrmForm">
<input type="hidden" name="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" value="[extensive data]" />

<script language="javascript">
<!--
function __doPostBack(eventTarget, eventArgument) {
var theform = document.forms["webfrmForm"];
theform.__EVENTTARGET.value = eventTarget.replace(/\$/g, ":");
theform.__EVENTARGUMENT.value = eventArgument;
theform.submit();
}
// -->
</script>
------------------------------------------------------------

The other asp page generates only this:

------------------------------------------------------------
<form name="wfrmPokedat" method="post" action="pokedat.aspx"
id="wfrmPokedat">
<input type="hidden" name="__VIEWSTATE" value="[data]" />
------------------------------------------------------------

The net result is that the first page can have objects onclick perform a
__doPostBack, and the other page throws a javascript error about an expected
object; and rightfully so, the __dopostback routine isn't there. But why
isn't it?

What triggers the asp.net creation of the __doPostBack code block? It's
also missing it's __EVENTTARGET and __EVENTARGUMENT hidden values. I can't
find any significant differences in either of my pages that would cause
this. I'm using framework 1.1 and 2003 rc2/iis6 server & notepad as an
editor.
 
E

E

I discovered that the difference between the pages was a combo box on the
first page had the autopostback property of true, whereas the other page did
not have this poperty specified at all. Setting this property to true on
the second page caused asp.net to auto-generate the postback block I was
looking for.

How else can I get asp.net to generate this block? I don't want my combo
box on the second page to autopostback...
 
R

Ram

You need to have atleast one web server control that has a
autopostback property to true. Otherwise that code block will not be
generated. Insert a server button on the page and the code block will
be generated.

Thanks
Ram

E said:
I discovered that the difference between the pages was a combo box on the
first page had the autopostback property of true, whereas the other page did
not have this poperty specified at all. Setting this property to true on
the second page caused asp.net to auto-generate the postback block I was
looking for.

How else can I get asp.net to generate this block? I don't want my combo
box on the second page to autopostback...


E said:
I have 2 aspx pages... neither of which do anything out of the ordinary.

One of the pages automatically generates this block of code when viewed at
the client:
------------------------------------------------------------
<form name="webfrmForm" method="post" action="pokedex.aspx" id="webfrmForm">
<input type="hidden" name="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" value="[extensive data]" />

<script language="javascript">
<!--
function __doPostBack(eventTarget, eventArgument) {
var theform = document.forms["webfrmForm"];
theform.__EVENTTARGET.value = eventTarget.replace(/\$/g, ":");
theform.__EVENTARGUMENT.value = eventArgument;
theform.submit();
}
// -->
</script>
------------------------------------------------------------

The other asp page generates only this:

------------------------------------------------------------
<form name="wfrmPokedat" method="post" action="pokedat.aspx"
id="wfrmPokedat">
<input type="hidden" name="__VIEWSTATE" value="[data]" />
------------------------------------------------------------

The net result is that the first page can have objects onclick perform a
__doPostBack, and the other page throws a javascript error about an expected
object; and rightfully so, the __dopostback routine isn't there. But why
isn't it?

What triggers the asp.net creation of the __doPostBack code block? It's
also missing it's __EVENTTARGET and __EVENTARGUMENT hidden values. I can't
find any significant differences in either of my pages that would cause
this. I'm using framework 1.1 and 2003 rc2/iis6 server & notepad as an
editor.
 
J

John Saunders

Take a look at Page.GetPostBackEventReference. It looks like it might have
to generate the script in order to get you a reference to it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top