Solved

works on localhost but not on webserver

Posted on 2013-12-23
7
266 Views
Last Modified: 2014-01-02
I am trying to make the Enter key work during login for my app at www.lucidequipment.com by setting up a default button in a panel.  The code works in localhost mode, but on the web server gives the often seen error about needing the default button to be of type IButtonControl. What am I doing wrong?

My best guess is that the button is not properly identified in the code behind.

Protected Sub Login1_PreRender(sender As Object, e As EventArgs)
        Dim btnLoginDefault As Button = TryCast(Login1.FindControl("LoginButton"), Button)
        pnlLogin.DefaultButton = btnLoginDefault.UniqueID
    End Sub

Open in new window

0
Comment
Question by:Mark Klein
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
7 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39736948
This is what I get from your web server:

Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET

Are those the same as you have on your computer at 'localhost'?
0
 

Author Comment

by:Mark Klein
ID: 39736978
that's the AspNet version. My default browser in Chrome, not MS.  Where do I find the IIS version?
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39736990
Browser doesn't matter because ASP.NET is run on the server.  IIS versions are tied to the Operating System.  See here: http://support.microsoft.com/kb/224609
0
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 

Author Comment

by:Mark Klein
ID: 39737860
I eventually realized that. I'm using Win7 in a dual boot setup on a Mac with Parallels, so IIS at 7.5 is probably OK.

Been doing this for a while w/o this problem.  I'm a relative newbie, a geezer back to programming after (literally) 50 years, so there is a lot I don't know. I built the app you see for my son, now doing defensive programming trying to handle users who press Enter instead of the button they should.

I suspect the problem is related to the button identifier, which changes during compilation. I am trying to make the button on the screen the defaultbutton in a panel.  I've seen several posts about this situation being "squirrely" in VWD, and some need to modify the UniqueID that I append to the the button ID.
0
 

Author Comment

by:Mark Klein
ID: 39739083
My code, shown below, is unable to find the button that I want assigned as the defaultbutton. Hence the Enter key is directed elsewhere, which is probably while it's failing.  From reading around the net, it seems that because this login page is coupled to a master page, that master page is causing the problem.

Protected Sub Login1_Load(sender As Object, e As System.EventArgs) Handles Login1.Load
        MyBase.LogActivity("Visiting the Login page.")
        Dim btnLoginDefault As Button = TryCast(FindControl("Login1$LoginButton"), Button)
        pnlLogin.DefaultButton = btnLoginDefault.UniqueID
    End Sub

Open in new window


I've set a breakpoint on the Dim line, and the breakpoint is reached. The code goes through here and fails here
0
 

Accepted Solution

by:
Mark Klein earned 0 total points
ID: 39743681
I "solved" the problem by not using the panel defaultbutton.  Inside the Load event for the page I put

  Dim FirstTextBox As TextBox = TryCast(Login1.FindControl("username"), TextBox)
        Page.Form.DefaultFocus = FirstTextBox.ClientID
        Dim btnLoginDefault As Button = TryCast(Login1.FindControl("LoginButton"), Button)
        Page.Form.DefaultButton = btnLoginDefault.UniqueID

Open in new window

I was led to this approach by

http://imar.spaanjaars.com/374/how-do-i-set-the-defaultfocus-or-defaultbutton-in-a-page-based-on-a-master-page-in-aspnet-20

Why the code based on the panel default button doesn't work, or why visual web developer led me astray by having my code work in localhost but not on web server, I still don't know
0
 

Author Closing Comment

by:Mark Klein
ID: 39750942
Had to solve this myself.  Still don't know why my original code only worked in localhost.
0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question