473,382 Members | 1,692 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Default button of a page

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

Feb 5 '07 #1
6 5623
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!
********************************************
<je**********@gmail.comwrote in message
news:11**********************@j27g2000cwj.googlegr oups.com...
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
Feb 5 '07 #2
Hi there,

If you have a loo
--
Milosz
"je**********@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

Feb 5 '07 #3
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)

je**********@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
Feb 5 '07 #4
"Milosz Skalecki [MCAD]" <mi*****@DONTLIKESPAMwp.plwrote in message
news:27**********************************@microsof t.com...
Hi there,

If you have a loo
Very useful, otherwise it can get really unpleasant underneath the desk...
;-)
Feb 5 '07 #5
Sorry guys, i pressed 'post' instead of 'close' :D
--
Milosz
"Mark Rae" wrote:
"Milosz Skalecki [MCAD]" <mi*****@DONTLIKESPAMwp.plwrote in message
news:27**********************************@microsof t.com...
Hi there,

If you have a loo

Very useful, otherwise it can get really unpleasant underneath the desk...
;-)
Feb 5 '07 #6
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

Feb 5 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Billy Jacobs | last post by:
Is there a way to make a button on a web form the default button so that when the user hits the enter button the code for that button executes? I have a web page Login.aspx where I have only 1...
2
by: Goober | last post by:
I have the following default.aspx page that works properly. However, what I want to do is to link the graphics within it (that are hard coded now in the default web page) to our corporate...
4
by: tshad | last post by:
I have 3 objects on my page (textbox,button and linkbutton) When I put something in my textbox and hit "enter", the page gets posted, but nothing happens. I don't go to either of the functions...
1
by: JJ | last post by:
I have two related problems: (a). trying to set the default button within a CreateUserWizard control ----------------------------------------------------------------- I've done this in a messy...
1
by: JJ | last post by:
What trouble I'm having setting default buttons on a page (with a master page). I got around doing it on a page basis by calling the SetWizardDefaultButton() routine from page load. Notice how...
2
by: Gregory Gadow | last post by:
I have a large website written to use ASP.Net 2.0. The master page has a "logout" button. If the child page does not have an explicitly defined default button (most do not), the page posts back...
2
by: AlecL | last post by:
Hi All, I have added a user control onto an aspx page and want to make the submit button of that user control the default button when the panel in which the user control is located is visible. ...
0
by: Glenn | last post by:
I currently have a page that contains a logon control and a Wizard control. I am having an issue when the user hits the "Enter" key, the user gets logged off. This is because the logon control...
0
by: =?Utf-8?B?bmVlcmFqYkBub2lkYS5ub3NwYW1oY2x0ZWNoLmNv | last post by:
Hi, We have created new .NET web service and running it through the default test page and it's working fine in our development environment. When we moved the web service to the acceptance...
0
by: thersitz | last post by:
Hi, Using aspnet3.5,VStudio 2008, VB 1.) I have a set of pages, with a search text box button within a userControl that searches across our websites and is registered in a masterpage. 2)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.