PC Review


Reply
Thread Tools Rate Thread

Default button of a page

 
 
jelle.huygen@gmail.com
Guest
Posts: n/a
 
      5th Feb 2007
Hello,

I've worked on a website in ASP.NET 2.0 where, on every page, login-
button of a login control is set as the default button. The login-
control is on the masterpage of the website. In the prerender-method
of the masterpage, I have placed the following code:

Login lg = (Login)lgView.FindControl("lgLogin");
if (lg != null)
{
Button btn = (Button)lg.FindControl("LoginButton");
if (btn != null)
Page.Form.DefaultButton = btn.UniqueID;
}

The website is running in a production environment and a couple of
times a day we get the following exception:

The DefaultButton of 'form1' must be the ID of a control of type
IButtonControl

I can't reproduce the exception; it appearce to occure randomly.

Does anyone experienced the same problem or does anyone have a
solution?

Kind regards,
Jelle

 
Reply With Quote
 
 
 
 
Cowboy \(Gregory A. Beamer\)
Guest
Posts: n/a
 
      5th Feb 2007
You may have to wrap the point where the code is causing an exception and
find a) the page it is happening on and b) the control it thinks it is
setting as default. The answer to those two questions will help you
determine why it is happening.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com

********************************************
Think outside the box!
********************************************
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello,
>
> I've worked on a website in ASP.NET 2.0 where, on every page, login-
> button of a login control is set as the default button. The login-
> control is on the masterpage of the website. In the prerender-method
> of the masterpage, I have placed the following code:
>
> Login lg = (Login)lgView.FindControl("lgLogin");
> if (lg != null)
> {
> Button btn = (Button)lg.FindControl("LoginButton");
> if (btn != null)
> Page.Form.DefaultButton = btn.UniqueID;
> }
>
> The website is running in a production environment and a couple of
> times a day we get the following exception:
>
> The DefaultButton of 'form1' must be the ID of a control of type
> IButtonControl
>
> I can't reproduce the exception; it appearce to occure randomly.
>
> Does anyone experienced the same problem or does anyone have a
> solution?
>
> Kind regards,
> Jelle
>


 
Reply With Quote
 
=?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=
Guest
Posts: n/a
 
      5th Feb 2007
Hi there,

If you have a loo
--
Milosz


"(E-Mail Removed)" wrote:

> Hello,
>
> I've worked on a website in ASP.NET 2.0 where, on every page, login-
> button of a login control is set as the default button. The login-
> control is on the masterpage of the website. In the prerender-method
> of the masterpage, I have placed the following code:
>
> Login lg = (Login)lgView.FindControl("lgLogin");
> if (lg != null)
> {
> Button btn = (Button)lg.FindControl("LoginButton");
> if (btn != null)
> Page.Form.DefaultButton = btn.UniqueID;
> }
>
> The website is running in a production environment and a couple of
> times a day we get the following exception:
>
> The DefaultButton of 'form1' must be the ID of a control of type
> IButtonControl
>
> I can't reproduce the exception; it appearce to occure randomly.
>
> Does anyone experienced the same problem or does anyone have a
> solution?
>
> Kind regards,
> Jelle
>
>

 
Reply With Quote
 
bruce barker
Guest
Posts: n/a
 
      5th Feb 2007
some form has a lgButton thats not a really a Login causing the cast to
blow. change your code to:

Login lg = lgView.FindControl("lgLogin") as Login;
if (lg != null)


-- bruce (sqlwork.com)

(E-Mail Removed) wrote:
> Hello,
>
> I've worked on a website in ASP.NET 2.0 where, on every page, login-
> button of a login control is set as the default button. The login-
> control is on the masterpage of the website. In the prerender-method
> of the masterpage, I have placed the following code:
>
> Login lg = (Login)lgView.FindControl("lgLogin");
> if (lg != null)
> {
> Button btn = (Button)lg.FindControl("LoginButton");
> if (btn != null)
> Page.Form.DefaultButton = btn.UniqueID;
> }
>
> The website is running in a production environment and a couple of
> times a day we get the following exception:
>
> The DefaultButton of 'form1' must be the ID of a control of type
> IButtonControl
>
> I can't reproduce the exception; it appearce to occure randomly.
>
> Does anyone experienced the same problem or does anyone have a
> solution?
>
> Kind regards,
> Jelle
>

 
Reply With Quote
 
Mark Rae
Guest
Posts: n/a
 
      5th Feb 2007
"Milosz Skalecki [MCAD]" <(E-Mail Removed)> wrote in message
news:2783E435-A210-4BD5-9C50-(E-Mail Removed)...

> Hi there,
>
> If you have a loo


Very useful, otherwise it can get really unpleasant underneath the desk...
;-)


 
Reply With Quote
 
=?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=
Guest
Posts: n/a
 
      5th Feb 2007
Sorry guys, i pressed 'post' instead of 'close'
--
Milosz


"Mark Rae" wrote:

> "Milosz Skalecki [MCAD]" <(E-Mail Removed)> wrote in message
> news:2783E435-A210-4BD5-9C50-(E-Mail Removed)...
>
> > Hi there,
> >
> > If you have a loo

>
> Very useful, otherwise it can get really unpleasant underneath the desk...
> ;-)
>
>
>

 
Reply With Quote
 
Alexey Smirnov
Guest
Posts: n/a
 
      5th Feb 2007
On Feb 5, 3:26 pm, jelle.huy...@gmail.com wrote:
> Hello,
>
> I've worked on a website in ASP.NET 2.0 where, on every page, login-
> button of a login control is set as the default button. The login-
> control is on the masterpage of the website. In the prerender-method
> of the masterpage, I have placed the following code:
>
> Login lg = (Login)lgView.FindControl("lgLogin");
> if (lg != null)
> {
> Button btn = (Button)lg.FindControl("LoginButton");
> if (btn != null)
> Page.Form.DefaultButton = btn.UniqueID;
> }
>
> The website is running in a production environment and a couple of
> times a day we get the following exception:
>
> The DefaultButton of 'form1' must be the ID of a control of type
> IButtonControl
>
> I can't reproduce the exception; it appearce to occure randomly.
>
> Does anyone experienced the same problem or does anyone have a
> solution?
>
> Kind regards,
> Jelle


It looks like it is an issue with MasterPage

Please check this
http://www.spaanjaars.com/QuickDocId.aspx?QUICKDOC=374

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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
How to set a button from a user control the default button on an aspx page AlecL Microsoft ASP .NET 2 12th Feb 2007 09:15 PM
2.0 Master Page Default Button =?Utf-8?B?Q2hyaWlz?= Microsoft ASP .NET 1 18th Nov 2005 09:07 PM
Re: Default Button for a web page Steve C. Orr [MVP, MCSD] Microsoft ASP .NET 0 1st Sep 2005 02:24 AM
Default Button in Web Page Bob Mixon Microsoft ASP .NET 4 19th Mar 2004 10:00 PM
default button on page John Holmes Microsoft ASP .NET 2 17th Dec 2003 06:59 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:54 AM.