ASP.NET bug

  • Thread starter Thread starter 00_CuMPe3WaR3D12
  • Start date Start date
0

00_CuMPe3WaR3D12

I was trying to add the style attributes on DropDownList but I couldn't, so
I found many articles on Google and people saying this is a bug. But in
microsoft support site, I found this:
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q309338

If I use Microsoft's workaround by using HtmlSelect, I lost the ability to
use autopostback. Is there any workaround??

According to microsoft, this is something called "behavior is by design"...
so they are not going to fix it in the next release?

Help...
 
<<According to microsoft, this is something called "behavior is by
design"...
so they are not going to fix it in the next release?>>

If this is "by design", then what is there to fix???
AFAIK, fix is something you do with a problem, not something you do to
something that is by design.
 
If you want to replicate the autopostback behaviour with HtmlSelect, you
need to use some javascript code to cause form submit on onchange event of
the HtmlSelect

Follow the following steps:

To your Form add the following hidden input fields

<input type="hidden" name="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" value="" />

then add this javascript to your page

<script language="javascript">
<!--
function __doPostBack(eventTarget, eventArgument) {
var theform;
if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) {
theform = document.forms["Form1"];
}
else {
theform = document.Form1;
}
theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
theform.__EVENTARGUMENT.value = eventArgument;
theform.submit();
}
// -->
</script>

then in your HtmlSelect element, call the javascript function as follows
onchange="javascript:{if (typeof(Page_ClientValidate) != 'function' ||
Page_ClientValidate()) __doPostBack('HtmlSelectID','');"

thts it. This should take care of the postback when you change something in
the select element


Please note that, I havent told you anything new, these are the steps
asp.net follows to generate autopostback for a dropdownlist. Over there
asp.net would take care of generating the javascript code, here you are
simply adding it, since the control is not asp.net server control

Let me know if you need more help

good luck
 
Okay dude, let me rephrase "Will they going to change the design and
implement that?" How's that noob?

Why is there a "workaround" published by Microsoft if the design is perfect?
tell me. Try to search on Google, tons of people saying this is something
should be implemented...many considered this is a bug too, I am not alone.
Try to flame all those posters if you got too much time.

C.P.
 
Thanks a lot!!! This is very helpful.


Kumar Reddi said:
If you want to replicate the autopostback behaviour with HtmlSelect, you
need to use some javascript code to cause form submit on onchange event of
the HtmlSelect

Follow the following steps:

To your Form add the following hidden input fields

<input type="hidden" name="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" value="" />

then add this javascript to your page

<script language="javascript">
<!--
function __doPostBack(eventTarget, eventArgument) {
var theform;
if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) {
theform = document.forms["Form1"];
}
else {
theform = document.Form1;
}
theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
theform.__EVENTARGUMENT.value = eventArgument;
theform.submit();
}
// -->
</script>

then in your HtmlSelect element, call the javascript function as follows
onchange="javascript:{if (typeof(Page_ClientValidate) != 'function' ||
Page_ClientValidate()) __doPostBack('HtmlSelectID','');"

thts it. This should take care of the postback when you change something in
the select element


Please note that, I havent told you anything new, these are the steps
asp.net follows to generate autopostback for a dropdownlist. Over there
asp.net would take care of generating the javascript code, here you are
simply adding it, since the control is not asp.net server control

Let me know if you need more help

good luck
--
Kumar Reddi
http://kumarreddi.blogspot.com

00_CuMPe3WaR3D12 said:
I was trying to add the style attributes on DropDownList but I couldn't, so
I found many articles on Google and people saying this is a bug. But in
microsoft support site, I found this:
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q309338

If I use Microsoft's workaround by using HtmlSelect, I lost the ability to
use autopostback. Is there any workaround??

According to microsoft, this is something called "behavior is by design"...
so they are not going to fix it in the next release?

Help...
 
AutoPostBack in HTMLSelect Workaround

Hi,

As there is no autopostback for HTMLSelect Control, U can use a Submit Button as hidden and which should be set as runat server. In OnChange Even of HTML Select Call the Click Event of Submit Button From Javascript Like Document.Form1.Submit1.Click(); and Handle whatever u want to do when HTML Select Value Changes in Submit_ServerClick()

N'Joy!!!
Raziq ((e-mail address removed))
 

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

Back
Top