Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > How to execute event code for DropDownList?

Reply
Thread Tools

How to execute event code for DropDownList?

 
 
Waldy
Guest
Posts: n/a
 
      05-08-2008
Hi there,
when you double click a drop down control on a web form, it
creates the OnSelectedIndexChanged function placeholder in the code behind
file. How do you then get that code to execute? Changing the selection of
the drop down does not return to the server even though I have the
runat=server tags on the controls. A button on the same page does run the
OnClick event code in when you click it. I tried setting the AutoPostback
setting to true, and then the page gets re-loaded, but it still does not
execute the attached event code.

What am I missing?


 
Reply With Quote
 
 
 
 
Peter Bucher [MVP]
Guest
Posts: n/a
 
      05-08-2008
Hello Waldy

> when you double click a drop down control on a web form, it
> creates the OnSelectedIndexChanged function placeholder in the code behind
> file. How do you then get that code to execute? Changing the selection
> of the drop down does not return to the server even though I have the
> runat=server tags on the controls. A button on the same page does run the
> OnClick event code in when you click it. I tried setting the AutoPostback
> setting to true, and then the page gets re-loaded, but it still does not
> execute the attached event code.

The only thing you need is to set AutoPostBack of the Control to "true".
You said, that its not working after that..... so let us see your Code,
to explore the issue...

--
Gruss, Peter Bucher
Microsoft MVP - Visual Developer ASP / ASP.NET, Switzerland
http://www.aspnetzone.de/ - ASP.NET Zone, die ASP.NET Community
http://www.aspnetzone.de/blogs/peterbucher/ - Auf den Spuren von .NET

 
Reply With Quote
 
 
 
 
Waldy
Guest
Posts: n/a
 
      05-08-2008
Hi there,

"Peter Bucher [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>so let us see your Code,


It's not easy as it is a large project. I created a new page to demonstrate
the problem and it works as expected on that page. What determines whether
or not event code is executed at the server? The output of the problem page
and the new page looks exactly the same as far as the dropdown is concerned.
The only javascript is calling the __doPostback method.


 
Reply With Quote
 
Peter Bucher [MVP]
Guest
Posts: n/a
 
      05-09-2008
Hi Waldy

> It's not easy as it is a large project. I created a new page to
> demonstrate the problem and it works as expected on that page.

ok

> What determines whether or not event code is executed at the server? The
> output of the problem page and the new page looks exactly the same as far
> as the dropdown is concerned. The only javascript is calling the
> __doPostback method.

This can vary by different things.
In the included ASP.NET Components is that mainly a Javascript caused
postback with some Parameters that match the ones where on the Server
expected.

Its now difficult to say whats the problem in your issue.
Please show the two similar small Parts of the output...
.... maybe theres a difference to catch.

--
Gruss, Peter Bucher
Microsoft MVP - Visual Developer ASP / ASP.NET, Switzerland
http://www.aspnetzone.de/ - ASP.NET Zone, die ASP.NET Community
http://www.aspnetzone.de/blogs/peterbucher/ - Auf den Spuren von .NET

 
Reply With Quote
 
Stan
Guest
Posts: n/a
 
      05-11-2008
On 8 May, 15:34, "Waldy" <(E-Mail Removed)> wrote:
> Hi there,
>
> "Peter Bucher [MVP]" <(E-Mail Removed)> wrote in messagenews:(E-Mail Removed)...
>
> >so let us see your Code,

>
> It's not easy as it is a large project. *I created a new page to demonstrate
> the problem and it works as expected on that page. *What determines whether
> or not event code is executed at the server? *The output of the problem page
> and the new page looks exactly the same as far as the dropdown is concerned.
> The only javascript is calling the __doPostback method.


Are you sure that the dropdown control is failing to postback?

If you are using Visual Studio and can run the project in debug mode,
one way to check this is to put a line or two of passive code in the
page_load event that executes when IsPostback is true. Then put a
debug break there. Run the page and click the dropdownlist. If it's
posting back then debug will halt it for you to see.

A much more common problem is the designated event code handler not
being executed on postback. This can happen after extensive editing
where event handling routines are liable to become orphaned. For
example if you place a control on the page, use the click method to
autogenerate an event "placeholder" then delete the control and put
back later leads to a situation where the original event code will not
be "wired up" to anything and the compiler just ignores it.

HTH
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
How to have multiple page execute same event code? ryanmhuc@yahoo.com ASP .Net 1 03-31-2006 07:24 PM
How to Execute Code Behind Code in Inline aspx Kamal Ahmed ASP .Net 1 10-25-2005 08:09 AM
Can i execute aspx file in my asp pag with server.execute method(sorry) Savas Ates ASP General 1 08-17-2004 04:52 PM
Fire Code behind code AND Javascript code associated to a Button Click Event =?Utf-8?B?Q2FybG8gTWFyY2hlc29uaQ==?= ASP .Net 4 02-11-2004 07:31 AM



Advertisments