Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

works on localhost but not on webserver

Posted on 2013-12-23
7
Medium Priority
?
269 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 84

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 84

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
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

705 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