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

x
?
Solved

dotnet: declare a linkbutton to make it invisible

Posted on 2004-09-22
21
Medium Priority
?
493 Views
Last Modified: 2012-05-05
<asp:datalist id="mydatalist" runat="server" OnDeleteCommand="procedures_dataset" OnUpdateCommand="procedures_dataset"
                        OnEditCommand="procedures_dataset" DataKeyField="Id">
      <ItemTemplate>
      <table>
      <tr>
      <td><%#Container.DataItem("GeboorteDatum")%></td>
      <td>
      <asp:Linkbutton CommandName="Edit" Runat="server" text="Edit"></asp:Linkbutton>
        <asp:Linkbutton id="DeleteButton" CommandName="Delete" Runat="server" text="Delete"></asp:Linkbutton>
      </td>
      </tr>


hi,
I need to declare in the code behind the linkbutton=DeleteButton
  Protected WithEvents DeleteButton As ??????

bcs i need to control this button in the code behind to make it sometimes invisible
  DeleteButton.Visible = False
tks

karel
0
Comment
Question by:karel_jespers
[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
  • 11
  • 8
21 Comments
 
LVL 20

Expert Comment

by:jitganguly
ID: 12123066
private void DeleteButton_Click(object sender, System.EventArgs e)
{
// your code here

}
0
 
LVL 20

Expert Comment

by:jitganguly
ID: 12123102
and you can also use Visible=false in HTML itself
0
 
LVL 6

Expert Comment

by:Mike_Metro
ID: 12123222
<asp:Linkbutton CommandName="Edit" Runat="server" text="Edit" Visible="False"></asp:Linkbutton>
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 6

Author Comment

by:karel_jespers
ID: 12125118
tks for you help

but i need to make the linkbutton invisible in the code behind using the visual basic behind the html

to do that i must declare the link button in the basic code *.aspx.vb source

i must declare it therefore

Protected WithEvents DeleteButton As ??????  <=================

how must i declare to access a link button within a datalist

tks
karel
0
 
LVL 20

Expert Comment

by:jitganguly
ID: 12125389
Put this in on Page_Load and see

DeleteButton.Visible = False
0
 
LVL 6

Author Comment

by:karel_jespers
ID: 12131325
tks for help,
i added the line to the page_load but then i receive an error msg telling met
DeleteButton is not declared
and this is where i m looking for
Protected WithEvents DeleteButton As ??????  <=how must i declare the linkbutton inside a datalist

karel

0
 
LVL 20

Expert Comment

by:jitganguly
ID: 12132780
Can I see your whoel code pls. HTML+Code behind
0
 
LVL 6

Author Comment

by:karel_jespers
ID: 12134554
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="vb_InlezenWijzigenDataViaDataset.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
      <HEAD>
            <TITLE>WebForm1</TITLE>
      </HEAD>
      <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
      <meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
      <meta content="JavaScript" name="vs_defaultClientScript">
      <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
      <form id="Form1" runat="server">
            <center><asp:checkboxlist id="check1" runat="server" OnSelectedIndexChanged="Check" TextAlign="Right" AutoPostBack="True">
                        <asp:ListItem checked="true">DATABASE => DATASET  klik hier na accept</asp:ListItem>
                        <asp:ListItem>Item 2</asp:ListItem>
                  </asp:checkboxlist><br>
                  <asp:label id="mess" runat="server"></asp:label><br>
                  <asp:datalist id="mydatalist" runat="server" OnDeleteCommand="procedures_dataset" OnUpdateCommand="procedures_dataset"
                        OnEditCommand="procedures_dataset" DataKeyField="Id">
                        <ItemTemplate>
                              <table>
                                    <tr>
                                          <td><%#Container.DataItem("Id")%></td>
                                          <td><%#Container.DataItem("Tekst")%></td>
                                          <td><%#Container.DataItem("Naam")%></td>
                                          <td><%#Container.DataItem("GeboorteDatum")%></td>
                                          <td>
                                                <asp:Linkbutton CommandName="Edit" Runat="server" text="Edit"></asp:Linkbutton>
                                                <asp:Linkbutton CommandName="Delete" Runat="server" text="Delete"></asp:Linkbutton>
                                          </td>
                                    </tr>
                              </table>
                        </ItemTemplate>
                        <EditItemTemplate>
                              <table>
                                    <tr>
                                          <td><%#Container.DataItem("Id")%></td>
                                          <td>
                                                <asp:Textbox runat="server" id="txtTekst" text='<%#Databinder.Eval(Container.DataItem, "Tekst") %>' >
                                                </asp:Textbox>
                                                <asp:Textbox runat="server" id="txtNaam" text='<%#Databinder.Eval(Container.DataItem, "Naam") %>' >
                                                </asp:Textbox>
                                                <asp:Textbox runat="server" id="txtGeboorteDatum" text='<%#Databinder.Eval(Container.DataItem, "GeboorteDatum") %>' >
                                                </asp:Textbox>
                                          </td>
                                          <td>
                                                <asp:Linkbutton CommandName="Update" Runat="server" text="Update"></asp:Linkbutton></td>
                                    </tr>
                              </table>
                        </EditItemTemplate>
                  </asp:datalist><br>
                  <asp:linkbutton id="acceptbutton" Runat="server" text="Accept"></asp:linkbutton><br>
                  <asp:linkbutton id="cancelbutton" Runat="server" text="Cancel"></asp:linkbutton><br>
                  <asp:linkbutton id="insertbutton" Runat="server" text="Insert=Nieuw record toevoegen"></asp:linkbutton><br>
                  <br>
                  <A onclick="javascript:window.close()" href="#">EXIT</A>
            </center>
      </form>
</HTML>



code behind is very long


Public Class WebForm1
    Inherits System.Web.UI.Page
    Protected WithEvents mess As System.Web.UI.WebControls.Label
    Protected WithEvents mydatalist As System.Web.UI.WebControls.DataList
    Private conn As SqlConnection
    Private mydataadapter As SqlDataAdapter
    Protected WithEvents acceptbutton As System.Web.UI.WebControls.LinkButton
    Protected WithEvents insertbutton As System.Web.UI.WebControls.LinkButton
    Protected WithEvents cancelbutton As System.Web.UI.WebControls.LinkButton
    Private mydataset As DataSet
    Protected WithEvents check1 As System.Web.UI.WebControls.CheckBoxList

.....
0
 
LVL 20

Expert Comment

by:jitganguly
ID: 12134684
Where is deletebutton declared ?
Is it something like

<asp:linkbutton id="deletetbutton" Runat="server" text="Accept"></asp:linkbutton><br>


you speak dutch ?
0
 
LVL 6

Author Comment

by:karel_jespers
ID: 12135715
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="vb_InlezenWijzigenDataViaDataset.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
      <HEAD>
            <TITLE>WebForm1</TITLE>
      </HEAD>
      <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
      <meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
      <meta content="JavaScript" name="vs_defaultClientScript">
      <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
      <form id="Form1" runat="server">
            <center><asp:checkboxlist id="check1" runat="server" OnSelectedIndexChanged="Check" TextAlign="Right" AutoPostBack="True">
                        <asp:ListItem checked="true">DATABASE => DATASET  klik hier na accept</asp:ListItem>
                        <asp:ListItem>Item 2</asp:ListItem>
                  </asp:checkboxlist><br>
                  <asp:label id="mess" runat="server"></asp:label><br>
                  <asp:datalist id="mydatalist" runat="server" OnDeleteCommand="procedures_dataset" OnUpdateCommand="procedures_dataset"
                        OnEditCommand="procedures_dataset" DataKeyField="Id">
                        <ItemTemplate>
                              <table>
                                    <tr>
                                          <td><%#Container.DataItem("Id")%></td>
                                          <td><%#Container.DataItem("Tekst")%></td>
                                          <td><%#Container.DataItem("Naam")%></td>
                                          <td><%#Container.DataItem("GeboorteDatum")%></td>
                                          <td>
                                                <asp:Linkbutton CommandName="Edit" Runat="server" text="Edit"></asp:Linkbutton>
                                                <asp:Linkbutton id="DeleteButton" CommandName="Delete" Runat="server" text="Delete"></asp:Linkbutton>
                                          </td>
                                    </tr>
                              </table>
                        </ItemTemplate>
                        <EditItemTemplate>
                              <table>
                                    <tr>
                                          <td><%#Container.DataItem("Id")%></td>
                                          <td>
                                                <asp:Textbox runat="server" id="txtTekst" text='<%#Databinder.Eval(Container.DataItem, "Tekst") %>' >
                                                </asp:Textbox>
                                                <asp:Textbox runat="server" id="txtNaam" text='<%#Databinder.Eval(Container.DataItem, "Naam") %>' >
                                                </asp:Textbox>
                                                <asp:Textbox runat="server" id="txtGeboorteDatum" text='<%#Databinder.Eval(Container.DataItem, "GeboorteDatum") %>' >
                                                </asp:Textbox>
                                          </td>
                                          <td>
                                                <asp:Linkbutton CommandName="Update" Runat="server" text="Update"></asp:Linkbutton></td>
                                    </tr>
                              </table>
                        </EditItemTemplate>
                  </asp:datalist><br>
                  <asp:linkbutton id="acceptbutton" Runat="server" text="Accept=Wegschrijven van wijzigingen"></asp:linkbutton><br>
                  <asp:linkbutton id="cancelbutton" Runat="server" text="Cancel=Wijzingen annuleren"></asp:linkbutton><br>
                  <asp:linkbutton id="insertbutton" Runat="server" text="Insert=Nieuw record toevoegen"></asp:linkbutton><br>
                  <br>
                  <A onclick="javascript:window.close()" href="#">EXIT</A>
            </center>
      </form>
</HTML>
0
 
LVL 6

Author Comment

by:karel_jespers
ID: 12135729
in this code , you find it, previous code was from  a wrong version
0
 
LVL 20

Expert Comment

by:jitganguly
ID: 12135751
I am lost here

This works perfectly in my machine

private void Page_Load(object sender, System.EventArgs e)
{
DeleteButton.Visible=False                        
}
0
 
LVL 6

Author Comment

by:karel_jespers
ID: 12135867
bsc i didnt entered a
   Protected WithEvents DeleteButton As System...
the basic code cannot work with the DeleteButton
I must declare it but dont know how

in your example did you put the html code the same
a linkbutton inside the itemtemplate of a datalist
0
 
LVL 20

Expert Comment

by:jitganguly
ID: 12143112
Back.Sorry got stuck yesterday. IS it solved yet ?

You have to declare like this

protected System.Web.UI.WebControls.Button Button1;

This is C#
I would get you VB
0
 
LVL 20

Expert Comment

by:jitganguly
ID: 12143129
VB would be

Protected WithEvents Deletebutton As System.Web.UI.WebControls.Button
0
 
LVL 6

Author Comment

by:karel_jespers
ID: 12143842
for one or another reason the linkbutton doesn't becomes unvisible

doesnt i have to put
Public WithEvents Deletebutton As System.Web.UI.WebControls.Button = New System.Web.UI.WebControls.Button



0
 
LVL 20

Expert Comment

by:jitganguly
ID: 12143869
? Didn;t  get u ?
I just hope you have the code in Page _Load

DeleteButton.Visible=False  

come to MSN IM, abhijitg is my id
0
 
LVL 6

Author Comment

by:karel_jespers
ID: 12155997
the code is there but apparently, the button stays visible
0
 
LVL 20

Accepted Solution

by:
jitganguly earned 1000 total points
ID: 12159936
Then there must be something else. Can you please post your full code with the latest changes you made
0
 
LVL 20

Expert Comment

by:jitganguly
ID: 12717218
A 'C' Grade ?
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

670 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