473,399 Members | 3,302 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,399 software developers and data experts.

conditionally create asp:button

I have an ascx file in which I want to sometimes create an asp:button
control based on a given value. Nothing I've tried has worked. How can I
accomplish this task?

Tim
Nov 18 '05 #1
4 1263
You could use a placeholder, and then create the button + add it to the
placeholder's controls. Or you could always create the button, and just set
its Visible property.
--
Pete
====
Audio compression components, DIB graphics controls, FastStrings
http://www.droopyeyes.com

Read or write articles on just about anything
http://www.HowToDoThings.com
Nov 18 '05 #2
Thank you for your reply.

I don't know how to accomplish the placeholder trick, or even what you mean,
being new to ASP.Net.

I attempted to do the Visible trick, but it didn't want to work. Here is a
what I did as part of my table:

<td>
<br>
<asp:Button id=register name=register runat=server Text=register
CausesValidation=False OnClick=register_Click></asp:Button>
<% if( TTUser.UsersExist() == 0 )
{
register.Visible = false;
}
%>

I know the function is being called and returning a zero. I don't get any
errors, but the button stays visible. Any thoughts?

Tim

"Peter Morris" <pe**@removethisbit.droopyeyes.com> wrote in message
news:uI**************@TK2MSFTNGP10.phx.gbl...
You could use a placeholder, and then create the button + add it to the
placeholder's controls. Or you could always create the button, and just set its Visible property.
--
Pete
====
Audio compression components, DIB graphics controls, FastStrings
http://www.droopyeyes.com

Read or write articles on just about anything
http://www.HowToDoThings.com

Nov 18 '05 #3
The visible trick is the most straightfoward. Try:

<asp:button id="register" runat="server" text="register"
CausesValidation=False OnClick="register_Click" />
<script runat="server" language="c#">
public void Page_Load(){
if (TTUser.UserExist() == 0){
register.Visible = false;
}
}
</script>

"Tim Wallace" <reply@this_group.com> wrote in message
news:eL**************@TK2MSFTNGP12.phx.gbl...
Thank you for your reply.

I don't know how to accomplish the placeholder trick, or even what you mean, being new to ASP.Net.

I attempted to do the Visible trick, but it didn't want to work. Here is a what I did as part of my table:

<td>
<br>
<asp:Button id=register name=register runat=server Text=register
CausesValidation=False OnClick=register_Click></asp:Button>
<% if( TTUser.UsersExist() == 0 )
{
register.Visible = false;
}
%>

I know the function is being called and returning a zero. I don't get any
errors, but the button stays visible. Any thoughts?

Tim

"Peter Morris" <pe**@removethisbit.droopyeyes.com> wrote in message
news:uI**************@TK2MSFTNGP10.phx.gbl...
You could use a placeholder, and then create the button + add it to the
placeholder's controls. Or you could always create the button, and just

set
its Visible property.
--
Pete
====
Audio compression components, DIB graphics controls, FastStrings
http://www.droopyeyes.com

Read or write articles on just about anything
http://www.HowToDoThings.com


Nov 18 '05 #4
Thanks, Karl. I didn't even think about adding a Page_Load on the ascx (in
fact, I didn't think I could). Works fine.

Tim

"Karl" <none> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
The visible trick is the most straightfoward. Try:

<asp:button id="register" runat="server" text="register"
CausesValidation=False OnClick="register_Click" />
<script runat="server" language="c#">
public void Page_Load(){
if (TTUser.UserExist() == 0){
register.Visible = false;
}
}
</script>

"Tim Wallace" <reply@this_group.com> wrote in message
news:eL**************@TK2MSFTNGP12.phx.gbl...
Thank you for your reply.

I don't know how to accomplish the placeholder trick, or even what you mean,
being new to ASP.Net.

I attempted to do the Visible trick, but it didn't want to work. Here is a
what I did as part of my table:

<td>
<br>
<asp:Button id=register name=register runat=server Text=register
CausesValidation=False OnClick=register_Click></asp:Button>
<% if( TTUser.UsersExist() == 0 )
{
register.Visible = false;
}
%>

I know the function is being called and returning a zero. I don't get

any errors, but the button stays visible. Any thoughts?

Tim

"Peter Morris" <pe**@removethisbit.droopyeyes.com> wrote in message
news:uI**************@TK2MSFTNGP10.phx.gbl...
You could use a placeholder, and then create the button + add it to the placeholder's controls. Or you could always create the button, and
just set
its Visible property.
--
Pete
====
Audio compression components, DIB graphics controls, FastStrings
http://www.droopyeyes.com

Read or write articles on just about anything
http://www.HowToDoThings.com



Nov 18 '05 #5

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

Similar topics

1
by: RSB | last post by:
Hi Every one, Having tuff time to make this work .. i want to have a button and on my form say Delete button. So once i click on it i want to confirm "Are you sure?" on the Client Side and if...
11
by: Frag | last post by:
Hi guys, I searched around without any clear answer. Tons of stuff, but nothing concrete. I am trying to call this Javascript function: function ButtonClicked() { alert("The button has...
0
by: Maziar Aflatoun | last post by:
Hi everyone, I have the following shopping cart (basket view). However, Delete button in my datagrid doesn't fire any events. Does anyone know why? (It's a user web control) <%@ Control...
4
by: z. f. | last post by:
Hi, I'm having an aspx page with a server form. i have a grid with a delete button and below the grid, another area with inputs for inserting new values and an "add" button for submiting the...
1
by: RUIZCJ | last post by:
Hi, I'm at my wits end!!! I have the following code. The submit button works on my home computer but when I copy the dll and the ASPX file to my host provider, the button does NOT fire. TIA...
8
by: tatemononai | last post by:
I had a beautiful script that was running, well, just beautifully. But then I decided to take a button that fired an event and place it inside a <asp:table. The event WILL NOT FIRE INSIDE THE...
4
by: BrianDH | last post by:
Hi I would ask this questiopn on the NG ASP but it would be days before anyone might respond. I am using vb.net code behind to create buttons to add to a web form. After the buttons are created...
0
by: RickL | last post by:
Hi, I'm fairly new to web application development and I'm creating an application for camera control, which leads to the question. I want to create a button that can respond to mouse down and...
4
by: Sean | last post by:
I have a situation whereby I need to modify the text string appearing on an ASP button with some text derived from a Javascript function. But I am unsure of the correct syntax to do so. ...
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?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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.