473,396 Members | 2,068 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,396 software developers and data experts.

Accessing Login Control's Button from Code-Behind

I'd like to add the following attributes to the Login control's Login Button
to create a CSS rollover effect. How can I access the control's login button
from the page's code-behind?

LoginButton.Attributes.Add("onmouseover", "this.className =
'buttonsmallover'");
LoginButton.Attributes.Add("onmouseout", "this.className = 'buttonsmall'");

--
Jeff Lynch
"Ramblings From A [Microsoft] Connected Universe"
http://codebetter.com/blogs/jeff.lynch
Feb 24 '06 #1
1 6932
Hi Jeff,

Welcome to the MSDN newsgroup.

From your description, I understand you have an ASP.NET 2.0 page which uses
the "LoginControl" and you're wondering how to get the reference to the
login button on the "LoginControl" so as to do some
customization(registering some client scripts), correct?

Based on my research, the "LoginControl" doesn't provide buildin property
for accessing the inner login button control. However, since the login
button is created as one child control in the "LoginControl"'s composite
control hierarchy, we can consider using the "Control.FindControl" to get
the reference of the login button. Form the client-side html source of a
test page containing login control, I find that the login button's id is
always assigned with "LoginButton" and login button's direct parent
NamingContainer is just the "LoginControl". Therefore, we can use the
"LoginButton" as the control id to call the "FindControl" method. For
example:

===============================
protected void Page_Load(object sender, EventArgs e)
{
Control ctrl = Login1.FindControl("LoginButton");

if (ctrl != null)
{
Button btn = (Button)ctrl;
btn.Attributes.Add("onmouseout", "alert(this.name);");

}
else
{
Response.Write("<br/>Null");
}

}

===============================

BTW, for such question on how to get a nested child control's reference in
a certain composite control, the ASP.NET web page's output trace is a good
helper. We can turn on the page's trace in the @Page directive so that the
runtime will printout the page's control hierarchy at the bottom of the
page's html content. e.g:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="login.aspx.cs"
Inherits="login" Trace="true" %>

This can greatly ease our work on inspecting the page's control structure.

Hope this helps.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


Feb 27 '06 #2

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

Similar topics

2
by: Tim Blackwell | last post by:
i have some php code pulling some data from a database and i need to access some of hte variables in java script. i've never done this before. how can i do it. eg. i'm loading a combo box...
14
by: clintonG | last post by:
This is an appeal for peer support sent to Microsoft as will be noted in closing. The Login control does not include a Cancel button. The only option is to convert the Login control to a...
9
by: Justin Engelman | last post by:
Hi, I have a website that uses an ISAPI filter that will redirect anyone going to any page on the site to an SSL login page (on a different website with the same root domain) if they do not have...
0
by: John | last post by:
Hi I am using a login in template mode as I have customised it. I have added an image as a 'New User' button using the following code; <a class="button" href="Default2.aspx"> <asp:Image...
5
by: Glen | last post by:
Does anybody know a way to make the button on the Login control be the default button on the page? I have a master page with an ImageButton and a content page with a Login control. When I enter...
4
by: sowencheung | last post by:
Hi, all The scenario is like this: I have a master page, contains two user controls, one is a search control, another is a login control. The server-side <form> is in the master page,...
5
by: Afshar | last post by:
Hi everybody there, I have a special Login page that wants users to enter 3 passwords rather than a single password. But can't do it with Login control. I tried following scenarios: 1. Put an...
6
by: AppleBag | last post by:
I'm having the worst time trying to login to myspace through code. Can someone tell me how to do this? Please try it yourself before replying, only because I have asked this a couple of times in...
5
by: SagarDoke | last post by:
suppose there are 2 files "1.html" and "login.html". from "1.html" i am opening second page "login.html". "1.html" contain one button with value "signin". when i clicked on that button login form...
0
by: daokfella | last post by:
I have a Login.aspx page that takes care of all my login procedures (validation, lockouts, password change requirements, password retrieval, etc.) It works like a charm. However, now I'd like a...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.