Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

dotnet: declare a linkbutton to make it invisible

Posted on 2004-09-22
21
Medium Priority
?
495 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
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

916 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