By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,533 Members | 2,102 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,533 IT Pros & Developers. It's quick & easy.

ASP.NET with Hyperlink Control

P: 1

This is sivakumar from India. Now I am learning to ASP.NET 2.0..

I have a doubt....

I have used in a one hidden field control, 2 label controls, 2 button controls and one hyperlink controls.

Expand|Select|Wrap|Line Numbers
  1. <asp:Label ID="Label1" runat="server" 
  2.         style="z-index: 1; left: 77px; top: 280px; position: absolute; height: 24px" 
  3.         Text="Label"></asp:Label>
  5. <asp:HiddenField ID="HiddenField1" runat="server" Value="welcome" />
  7. <asp:Button ID="Button2" runat="server" 
  8.         style="z-index: 1; left: 385px; top: 275px; position: absolute" Text="Button" />   
  10.     <asp:Label ID="Label2" runat="server" 
  11.         style="z-index: 1; left: 291px; top: 285px; position: absolute; right: 473px" 
  12.         Text="Label"></asp:Label>
  14.     <asp:Button ID="Button1" runat="server" 
  15.         style="z-index: 1; left: 166px; top: 279px; position: absolute" Text="Button" />
  17.  <asp:HyperLink ID="Hyperlink1" runat="server" 
  18.         NavigateUrl="" 
  19.         style="z-index: 1; left: 182px; top: 418px; position: absolute; height: 19px">google</asp:HyperLink>
In hidden field control must for 2 properties...value and visible..

when will u click first button display the Hidden field property value display on the first label control..

Label1.Text = HiddenField1.Value

when will u click second button display the Hidden field property visible display on the second label control..

Label2.Text = HiddenField1.Visible

when i have clicked button2 control on that time hyperlink work on that page...

Its goto the google site.....I didnt touch the hyperlink control...

I want coding this example...

My ID: [email removed]
Jun 22 '09 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 5K+
P: 9,731
Hi sivakumar!

Welcome to Bytes. I hope you like it here :)

Clicking a button should never click a hyperlink.
However you can mess things up using CSS styles.

I think that's probably your problem...
I copied your ASP markup and discovered that your style is pretty weird.

Right now you're using absolute styles to arrange your elements and you're setting the z-index of your elements...the clickable area for the hyperlink is probably over top of the button even though it's text is displayed below the button and so when you click the button the hyperlink is activated (because you set the height of the hyperlink).

Why are you doing what you're doing?
What are you trying to accomplish?

Why don't you just group the Labels and Buttons into a section (like a <div>) and then apply CSS to move the section as a group?

Avoid using the CSS style position:absolute if don't want your elements to appear on top of the rest of the page content...

Why are you even using this style?

This is what I suggest you do to fix the problem:

I kept the position:absolute style but instead of moving each individual element to a place on the page I moved the entire group of elements.

I used a border and set the background-color of each section so that you can see what I've done.

Please note that the entire thing will appear on top of the rest of the page content because of the position:absolute style. If you remove this style the elements will be drawn within the page content.

Expand|Select|Wrap|Line Numbers
  1. <div id="Grouping" style="top: 275px; left: 77px; position: absolute; border: solid 1px #B0C4DE; background-color: #CAE1FF">
  2.     <asp:Label ID="Label1" runat="server" Style="height: 24px;" Text="Label1"></asp:Label>
  3.     <asp:Button ID="Button1" runat="server" Text="Button1" Style="margin-left: 45px;" />
  4.     <asp:Label ID="Label2" runat="server" Text="Label2" Style="margin-left: 45px;"></asp:Label>
  5.     <asp:Button ID="Button2" runat="server" Text="Button2" Style="margin-left: 45px;" />
  6.     <asp:HiddenField ID="HiddenField1" runat="server" Value="welcome" />
  7.     <div style="text-align: center; margin-top: 120px; border: solid 1px #708090; background-color: #A2B5CD;">
  8.         <asp:HyperLink ID="Hyperlink1" runat="server" NavigateUrl="" Text="google"></asp:HyperLink>
  9.     </div>
  10. </div>
Jun 23 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.