add hyperlink to customized username area in aspx webpage - c#

In my aspx web page there is one area to display username like Hi, Sruthy. It is customized to each user. So now I want to add hyperlink to this area how can I do it?
So my code is:
<div id="Displayname" class="displayName" runat="server">
<a href="Personalinfo.aspx" target=_blank></a>
</div>

you can use <asp:Hyperlink>
HTML
<asp:HyperLink id="hl1"
NavigateUrl="#"
Text=""
runat="server"/>
C#
you can alter the href or Text in C# using
hl1.NavigateUrl = "#";
hl1.Text = "Hi,Sruthy";

Related

Anchor tag not working properly in asp.net

in aspx
<a id="anchorViewMore" runat="server" > View More</a>
in backend c#
anchorViewMore.HRef = "www.google.com";
output im getting
http://localhost:3180/seoapp%20april%2017%20keyword%20assign%20by%20TL%20-%20backup/www.google.com
i want that href should be only "google.com" and should redirect to that website
Try:
anchorViewMore.HRef = "http://www.google.com";
If you don't put the 'http://' then it will link relative to the page you are on.
To make it open in a new window, you need to change the HTML to:
<a id="anchorViewMore" runat="server" target="_blank"> View More</a>

Display of html contents in C#

I want to display PDF to HTML contents parallel. For the conversion I used iTextSharp from PDF to HTML. The HTML contents are in a format like:
<span style="background: cyan">NLJJCN+BellMT</span>
<span style="background: cyan">11.353696472168pt</span>
so I tried with div to display the contents it was overlapping .. then label same problem as div. At last I tried HTMLeditor
<asp:TextBox ID="txtb_output" runat="server" TextMode="MultiLine" width=" 493px" height=" 485px" ></asp:TextBox>
<asp:HtmlEditorExtender ID="HtmlEditorExtender2" runat="server" TargetControlID="txtb_output"></asp:HtmlEditorExtender>
but in this it was not taking style .. normally text was displayed. Can anyone please help me how can I display the HTMLcontents in the browser. I am working on web application.
Thank you in advance
If I did not misunderstand, you have some html and you just want to show it on the browser from code-behind? If it is so, you can place a Literal control with Mode="PassThrough" and assign its Text property from code-behind. e.g.
aspx markup:
<asp:Literal ID="lt" Mode="PassThrough" runat="server" />
code-behind:
//...
lt.Text = "<span style='background-color:red'>It works!</span>";

How to change image without refreshing the page

I have a website where the user can select different cards. I need a way where when a new card is selected then the page does not refresh. When I click the back button now it just goes back to previous selections. I need it to go back to the previous page. Here is the code for the image change
<div class="imgCard" style="padding-right: 50px">
<asp:ScriptManager ID="ScriptManager" runat="server" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="conditional">
<ContentTemplate>
<fieldset style="border-width: 150px; border-style: none">
<asp:Image ID="imgCardChoice1" runat="server" />
<br />
<br />
<a id="openChange1" href="#" style="color: Red">Change Card</a>
</fieldset>
</ContentTemplate>
</asp:UpdatePanel>
</div>
When the user clicks on "Change Card" then a jquery modal box opens and allows them to change the card. Thank you for any help/advice. If needed the code behind to select a new card is in C#.
Without knowing more, it sounds like you need to use AJAX to do that. If you are already using jQuery, check out jQuery.load(). You can make an AJAX request to a url on your site that will only return the image information and load that into the element you specify.
Here is a link to the docs:
http://api.jquery.com/load/
Try to use some javascript function.
create a div where you want to put your image.
then give him an ID, on javascript function call the div id and change the src to the image that you want to put.
on your link or wathever you have to change the image, call the onclick function and use the javascript function.
On my website i have 2 images, that onmouseover change an image in other div completely different.
see it on:http://roundhillevents.com
and pass the cursor on the facebook and on the youtube logo's.
If nothing appears, let stay the cursor over that a little while.
PS: Only works with forefox and don't know why.

How to retrieve HTML control values which are placed in contentPlaceHolder in code behind file?

I've designed a web site. In that web site I used master page for my web page . And in that web page I've placed HTML controls which are in the content place holder. I want to retrieve values of the HTML control in the code behind file. How to do this?
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<div>
<span>
<select id="Select1">
<option value="1">Low</option>
<option value="2">Medium</option>
<option value="3">High</option>
<option value="4">Not Assigned</option>
</select></span>
<span>
<input id="Text1" type="text" /></span>
<span>
<asp:Button ID="Button1" runat="server" Text="Button"
onclick="Button1_Click" />
</span>
</div>
</asp:Content>
I want to retrieve the HTML control value on the click event of the Button1.
As TBohnen.jnr says, you can mark them as runat="server".
If you don't want to do that then you can use Request.Form["idOfInput"], but that's not generally recommended when using WebForms.
Mark them as runat="server" on the aspx page and give them an ID and you should see them in the code behind
****Edit****
You can alternatively just use an ajax call either via web method or do a seperate postback to send only the data you want if you are worried about performance.
Have a look at this article.

Access a div inside ListView in codebehind

I have a div with id="myDiv" and runat="server" inside a listview with id="lvItem".I need to access the div in code behind to add width of the div at runtime.How can I access the div from codebehid using C#?Can anyone help me?
Just add an Asp:Panel instead. Asp:Panel in ASP.NET = DIV on the front end.
So basically this would be your code
ASP.NET
<asp:Panel id="myDiv" runat="server">
</asp:Panel>
Code Behind
Panel myDiv = (Panel)myListView.FindControl("myDiv");
myDiv.Attributes.Add("style", "width: 100px");
<div id="coolmenu" runat="server">
</div>
HtmlControl htmlDivControl = (HtmlControl)Page.FindControl("coolmenu");
(htmlDivControl.Style["width"]) ="30px";

Categories

Resources