Solved

My asp:label doesn't show my text ID.

Posted on 2011-09-16
6
352 Views
Last Modified: 2013-12-17
My If statement is working fine... I'd like to show the following label in my .ascx code. Could you please adjust my code

protected System.Web.UI.WebControls.Label searchInstructions;

protected void Page_Load(object sender, EventArgs e)
        {
            // Set Go Button
            _ibtGo.ImageUrl = "/common/images/misc/button_go_grey-e.gif";

            // english Category
            searchInstructions.Text = "Artist Name:";
           

            if (Sitecore.Context.Language.ToString() == "fr")
            {
                _ibtGo.ImageUrl = "/common/images/misc/button_go_grey-f.gif";
               
                // french Categorie
                searchInstructions.Text = "Nom de l'artiste:";
            }              
        }

================
This is my output
-------------------------
 <TR>
                  <TD colSpan="2">
                        <P><BR>
                              <asp:Label id="searchInstructions" for="TextBox" runat="server">Label</asp:Label></P>
                  </TD>
      </TR>
      <tr>
            <td width="10%"><asp:TextBox ID="_txtSearch" runat="server" CssClass="main"></asp:TextBox></td>
            <td width="90%" valign="bottom"><asp:ImageButton ID="_ibtGo" runat="server" OnClick="_ibtGo_OnClick" /></td>
      </tr>
0
Comment
Question by:LelloLello
[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
  • 3
  • 2
6 Comments
 
LVL 28

Assisted Solution

by:strickdd
strickdd earned 250 total points
ID: 36550549
Do you have the "searchInstructions" label in the code-infront (HTML markup)? If you don't, then you need to add it to the markup and remove it from the first line of your posted code. Alternatively, you can keep the same code you posted, but you have to add the label to the control collection... for example:

this.Controls.Add(searchInstructions);
0
 

Author Comment

by:LelloLello
ID: 36550859
Hi Strickdd,

Here is the code, please advice where I should put it. I'm new in C#.

 ContentSearchableListOfWorks.ascx ContentSearchableListOfWorks.asc.cs

Thankyou.
0
 
LVL 28

Expert Comment

by:strickdd
ID: 36550929
I'm not sure if this is how it is or if it was just during the posting, but the first issue I see is that your code-behind file is called "ContentSearchableListOfWorks.asc.cs" - missing an "x". It should be "ContentSearchableListOfWorks.ascx.cs"

Next, is this .Net 1.1? If it is .Net 2.0+, then you shouldn't be declaring all your controls in the code-behind and since you are using partial classes, I believe you are on 2.0+. This leads me to believe that the missing "x" is probably the problem.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 7

Accepted Solution

by:
NauticalNonsense earned 250 total points
ID: 36557774
Try using the IDE to delete and create another label called searchInstructions. I remember sometimes that used to get funky with 1.1 legacy stuff.
0
 

Author Comment

by:LelloLello
ID: 36561000
strickdd / NauticalNonsense:

it is a type error but it's good in my message. could you please advice why

// english Category
            searchInstructions.Text = "Artist Name:";

is not showing the value of my label
<asp:Label id="searchInstructions" for="TextBox" runat="server"></asp:Label></P>

Everythins is displaying so the code is correct but why is not showing the value of my label??

NauticalNonsense:  Explain how can u do that i my code.
0
 

Author Comment

by:LelloLello
ID: 36567927
Hello Strick,

That the missing "x" is probably the problem.  Any idea why is not working?
0

Featured Post

Is Your DevOps Pipeline Leaking?

Is your CI/CD pipeline a hodge-podge of randomly connected tools? You’ve likely got a tool to fix one problem & then a different tool to fix another, resulting in a cluster of tools with overlapping functionality. Learn how to optimize your pipeline with Gartner's recommendations

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

729 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