Solved

works on localhost but not on webserver

Posted on 2013-12-23
7
262 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
  • 5
  • 2
7 Comments
 
LVL 82

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 82

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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared 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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now