473,698 Members | 2,869 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1272
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
CausesValidatio n=False OnClick=registe r_Click></asp:Button>
<% if( TTUser.UsersExi st() == 0 )
{
register.Visibl e = 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**@removethi sbit.droopyeyes .com> wrote in message
news:uI******** ******@TK2MSFTN GP10.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"
CausesValidatio n=False OnClick="regist er_Click" />
<script runat="server" language="c#">
public void Page_Load(){
if (TTUser.UserExi st() == 0){
register.Visibl e = false;
}
}
</script>

"Tim Wallace" <reply@this_gro up.com> wrote in message
news:eL******** ******@TK2MSFTN GP12.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
CausesValidatio n=False OnClick=registe r_Click></asp:Button>
<% if( TTUser.UsersExi st() == 0 )
{
register.Visibl e = 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**@removethi sbit.droopyeyes .com> wrote in message
news:uI******** ******@TK2MSFTN GP10.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******** ********@TK2MSF TNGP11.phx.gbl. ..
The visible trick is the most straightfoward. Try:

<asp:button id="register" runat="server" text="register"
CausesValidatio n=False OnClick="regist er_Click" />
<script runat="server" language="c#">
public void Page_Load(){
if (TTUser.UserExi st() == 0){
register.Visibl e = false;
}
}
</script>

"Tim Wallace" <reply@this_gro up.com> wrote in message
news:eL******** ******@TK2MSFTN GP12.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
CausesValidatio n=False OnClick=registe r_Click></asp:Button>
<% if( TTUser.UsersExi st() == 0 )
{
register.Visibl e = 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**@removethi sbit.droopyeyes .com> wrote in message
news:uI******** ******@TK2MSFTN GP10.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
2177
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 client select "Cancel" then i want to ignore the action and if "OK" selected then i want to Execute a Server side Event or Procedure. Now what is happening here is for "Delete1" button (in my code) even if Client Select Cancel it is still...
11
4651
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 been clicked."); }
0
1574
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 Language="c#" AutoEventWireup="false" Codebehind="ShoppingCart.ascx.cs" Inherits="TPShoppingCart.ShoppingCart1" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%> <asp:datagrid id="DGShoppingCart" AutoGenerateColumns="False" Width="650"
4
2283
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 lower area of the form. on the lower area i have validators for validating input.
1
3630
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 RuizCJ
8
3887
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 TABLE!?! When I move the button outside the table, it works just fine. Inside the table, it doesn't. What gives?
4
1747
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 I get this error: ((Control '_ctl0' of type 'Button' must be placed inside a form tag with runat=server.)) My Code example:
0
1045
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 mouse up events on the client-side. For example, suppose you have a button to control the zoom lens on a camera. When you click down on the mouse, the button would send a Zoom In command. When you release the mouse, the button would send a...
4
2010
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. Currently the I am just modifying the text in a SPAN next to the button as opposed to change the button text itself. But it's not ideal really. Currently I am have this: <div id="section2">
0
8603
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9157
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8893
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7723
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4366
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2328
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.