Solved

ASP .net Label and javacript href link visible

Posted on 2014-12-15
6
433 Views
Last Modified: 2014-12-17
Hi Expert,

I have two Label in aspx page, and I want them visible by contidtion

<asp:Label ID ="lb1" runat = "server" Text = "Complete a <a href='javascript:openForm(1);'>Information change form</a> if any details about your information changed." />

<asp:label ID = "lb2" runat = "server" Text="If this information incorrect, please update:"></asp:label><asp:LinkButton ID="lnkInfo" runat="server"
                    href="javascript:customConfirm(‘Are you sure you want to exit this screen?','../UpdateInfo/Update.aspx', null, true)"
                    Text="Update Account Information"></asp:LinkButton>

In code behind page

If ABC is true then
lb1.visible = true
lb2.visible=false
else
lb1.visible = false
lb2.visible=true
end if

lb1 work correctly and lb2 always visible.

How I can make lb2 work?

Thanks in advance.
0
Comment
Question by:dshi15
[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
  • 3
6 Comments
 
LVL 12

Expert Comment

by:Ammar Gaffar
ID: 40502014
Hi dshi15,

The code you submitted must work unless your condition if ABC = true is always return false. You need to check this condition output first, you can place break point in your first line if ABC=true and then press F10 to see what is next step.

Or you can make both label visibly to false as default and run your code, if it is showing label 1 in all cases then for sure the issue in your condition.
<asp:Label ID ="lb1" runat = "server" Text = "Complete a <a href='javascript:openForm(1);'>Information change form</a> if any details about your information changed."  visible="false" />

<asp:label ID = "lb2" runat = "server" Text="If this information incorrect, please update:" visible="false"></asp:label><asp:LinkButton ID="lnkInfo" runat="server"
                    href="javascript:customConfirm(‘Are you sure you want to exit this screen?','../UpdateInfo/Update.aspx', null, true)"
                    Text="Update Account Information"></asp:LinkButton>

Open in new window



Good Luck
0
 
LVL 1

Author Comment

by:dshi15
ID: 40503774
Hi Expert,

I tested contition it works fine. lb1 can change visible true or false based on condition, but lb2 always visible and I checked an online article and it said href link need be inside Label. This is exactly lb1 did, now i need change label2 same way, remove linkbutton and add href link inside Label2 tag, I just don't know how to do it. Because there are several single quote invovled.

Thank you.
0
 
LVL 12

Expert Comment

by:Ammar Gaffar
ID: 40504189
Hi,
Just hide your linlbutton (lnkInfo ) as well

If ABC is true then
lb1.visible = true 
lb2.visible=false
lnkInfo.visible = false
else
lb1.visible = false
lb2.visible=true
lnkInfo.visible = true
end if

Open in new window

0
Technology Partners: 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 1

Author Comment

by:dshi15
ID: 40504870
Yes, it is exactly I did, but Label2 and lnkInfo always visible. So I need remove a link button and add  href inside Label2 I guess.
0
 
LVL 12

Accepted Solution

by:
Ammar Gaffar earned 500 total points
ID: 40505012
Hi,
You are using link button, and there is no href property for the link button.
Anyway, you can use div (run at server) as a container for your label and link button see code block bellow:
<div id="myDiv" runat ="server" visible ="false">
<asp:label ID = "lb2" runat = "server" Text="If this information incorrect, please update:"></asp:label><asp:LinkButton ID="lnkInfo" runat="server"
                    href="javascript:customConfirm(‘Are you sure you want to exit this screen?','../UpdateInfo/Update.aspx', null, true)"
                    Text="Update Account Information"></asp:LinkButton>
</div>

Open in new window


And in you code:
If ABC is true then
lb1.visible = true 
myDiv.visible = false
else
lb1.visible = false
myDiv.visible = true
end if

Open in new window


Good Luck
0
 
LVL 1

Author Closing Comment

by:dshi15
ID: 40505818
Thank you very much and I found the usercontrol in the page which have Label2 visible with no condition and so sorry about that.
0

Featured Post

 Watch the Recording: Learning MySQL 5.7

MySQL 5.7 has a lot of new features. If you've dabbled with an older version of MySQL, it is definitely worth learning.

Question has a verified solution.

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

Thoughout my experience working on eCommerce web applications I have seen applications succumbing to increased user demand and throughput. With increased loads the response times started to spike, which leads to user frustration and lost sales. I ha…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.
Suggested Courses

636 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