i want to open link in new tab how to change my code to open link in new tab
<button onclick="location.href='<%#Eval("ReportLinks")%>'," title='<%#Eval("ReportLinks")%>'> Link</button>
Use a small t instead of a capital T for target like this:
<ItemTemplate> </asp:Label>
</ItemTemplate>
<asp:TemplateField HeaderText="Total Unique Links">
<ItemTemplate><a href='LinkDetails.aspx?val1=total' Target="_blank"><asp:Label ID="lblUsername" ForeColor="#1A0DAB" ToolTip="all links report" runat="server" Text='<%# Eval ("Total") %>' ></asp:Label>
</a>
</ItemTemplate>
Related
I have a Gridview contains many Template-Fields.
I want to make the width of a label in my html source equal to a value saved in my database. Here is the code I am trying but it is not working:
<asp:TemplateField HeaderText="Status" ItemStyle-Width="200px">
<ItemTemplate>
<asp:Label BackColor="#6699ff" Width="<%#
Eval("Status").ToString() %>" runat="server"> </asp:Label>
<%# Eval("Status").ToString() %>%
</ItemTemplate>
</asp:TemplateField>
U can do something like this:
span.gridLabel
{
display:block;
/*You can change to display:inline-block if you want Label and %Value in same line.*/
}
And your template field:
<asp:TemplateField HeaderText="Status" ItemStyle-Width="200px">
<ItemTemplate>
<span class="gridLabel" style='width:<%# Eval("Status").ToString() %>px; Background:#6699ff'> </span>
<%# Eval("Status").ToString() %>%
</ItemTemplate>
</asp:TemplateField>
I have check.aspx file which has:
<%# MasterType VirtualPath="~/MSW.master" %>
And in this master file I have:
<%# Register Src="UserControls/Common/StatusBar.ascx" TagName="StatusBar" TagPrefix="uc3" %>
And in this StatusBar.ascx, I have a div:
<div id="status_box_content">
<asp:Label ID="lblWelcome" runat="server" Text="Welcome " ></asp:Label>
<asp:Label ID="lbUser" runat="server"meta:resourcekey="lblFullNameResource1"></asp:Label>
<asp:Label ID="lblPartnerInfo" runat="server" ></asp:Label>
<asp:HyperLink Font-Underline="False" NavigateUrl="~/profile/Logout.aspx"
ID="HLinkLogout" runat="server" meta:resourcekey="HLinkLogoutResource1">Logout</asp:HyperLink>
</div>
I want this div with id ="status_box_content" to be invisible in check.aspx file. But everything else from master file is needed.
How do I make the div invisible while keeping the master file?
In your check.aspx, hide the div using jquery. It works perfectly fine. I was making a huge mistake while calling it.So yeah,it works! :)
Notes: Make your div runat="server"
Aspx Page
<div id="status_box_content" runat="server">
<asp:Label ID="lblWelcome" runat="server" Text="Welcome " ></asp:Label> <asp:Label ID="lbUser" runat="server"meta:resourcekey="lblFullNameResource1"></asp:Label>
<asp:Label ID="lblPartnerInfo" runat="server" ></asp:Label>
<asp:HyperLink Font-Underline="False" NavigateUrl="~/profile/Logout.aspx"
ID="HLinkLogout" runat="server" meta:resourcekey="HLinkLogoutResource1">Logout</asp:HyperLink>
</div>
Code Behind Page : Put This Code in your content page_load event
HtmlGenericControl DivCount = (HtmlGenericControl)Page.Master.FindControl("status_box_content");
DivCount.Visible = false;
Make runat= server to your div.
And then on page load of check.aspx use make that div invisible:
this.Master.findcontrol("divname").visible= false;
As the div is inside UserControl and User Control is inside Master Page, just try to access UserControl First in your page, then find out div and make it invisible. You could try out this:
First make the div as server control,Add runat="server" in div :
<div id="status_box_content" runat="server">
UserControl uc = ((UserControl)this.Master.FindControl("ucTopUser"));
HtmlGenericControl div = (HtmlGenericControl )uc.FindControl("status_box_content");
div.Visible = false;
I am trying to build a three level left navigation for my application using asp.net repeater and html list
I have three nested repeater with a linkbutton inside
when i click the linkbutton the list class should be active ( i have css for this active class).I am not good in Jquery
below is my code ( now i used only two repeater),Kindly help me how can i do this?
<ul class="nav nav-list mb-xl show-bg-active">
<asp:repeater ID="rep1" runat="server" DataSourceID="SqlDataSource1">
<ItemTemplate>
<li class="">
<asp:LinkButton ID="LinkButton1" runat="server" Text='<%# Eval("Menu") %>'></asp:LinkButton>
<asp:repeater ID="rep2" runat="server" DataSourceID="SqlDataSource1">
<ItemTemplate>
<ul>
<li>
<asp:LinkButton ID="LinkButton2" CommandArgument="id" runat="server" Text='<%# Eval("Menu") %>'></asp:LinkButton>
</li> </ul>
</ItemTemplate>
</asp:repeater>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:KTCWEBConnectionString %>" SelectCommand="SELECT NAVIAGATE_1.Menu FROM NAVIAGATE INNER JOIN NAVIAGATE AS NAVIAGATE_1 ON NAVIAGATE.ID = NAVIAGATE_1.ParentID WHERE (NAVIAGATE.Menu = #menu)">
<SelectParameters>
<asp:ControlParameter ControlID="LinkButton1" Name="menu" PropertyName="text" />
</SelectParameters>
</asp:SqlDataSource>
</li>
</ItemTemplate>
</asp:repeater>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:KTCWEBConnectionString %>" SelectCommand="SELECT DISTINCT Menu, ParentID, ID FROM NAVIAGATE WHERE (NOT (ParentID IS NULL)) AND (ParentID = 2)"></asp:SqlDataSource>
</ul>
So it's been a while since I've done ASP.Net controls but...
Your inner lists would need to bind the Enabled property to something in your Controller. Then when something is clicked you just set that binding to false. This should in turn disable all those buttons and if your css is written correctly (tier2:disabled) it should pick it up correctly.
That said, if this is a new application, stop using ASP.NET controls, it should have been killed a long time ago. HTML + CSS + ReactJs or KnockoutJs is the way to go now-a-days!
I have been trying to apply Eval on textbox which its mode is TextMode="Date". The date is not loading in to the text box and this is because the textmode. It seems to be that the Eval format is not working at all. When I remove the textmode it works. I have been trying several on variations and non of them have worked.
Here is some of them:
<asp:TextBox ID="birthdayTB" runat="server" Text='<%# Convert.ToDateTime(Eval("Birthday")).ToString("d") %>' TextMode="Date"></asp:TextBox>
<asp:TextBox ID="birthdayTB" runat="server" Text='<%# Eval("Birthday", "{0:dd-MM-yyyy}") %>' TextMode="Date"></asp:TextBox>
<asp:TextBox ID="birthdayTB" runat="server" Text='<%# Eval("Birthday", "{0:d}") %>' TextMode="Date"></asp:TextBox>
How can I make this work?
Thank you.
Use on code behind
birthdayTB.Text = Convert.ToDateTime(Birthday).ToString("dd-MM-yyyy");
Ok guys, I know this question has been asked a million times. I've searched for days and none of the online solutions found actually work for me. Here's my code:
<asp:SqlDataSource
ID="SqlDataSource2"
runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>"
SelectCommand="SELECT VTPNAME, NETWORKKEY, FKVTPDOMAIN, VLANNUMBER, NETDESCRIPTION, BEGINNINGIP,
HOSTS, DEFAULTGATEWAY FROM NETWORK.NETWORK, NETWORK.VTPDOMAIN WHERE
NETWORK.FKVTPDOMAIN = VTPDOMAIN.VTPDOMAINKEY"
DeleteCommand="DELETE FROM NETWORK.NETWORK WHERE NETWORKKEY =: NETWORKKEY"
UpdateCommand="UPDATE NETWORK.NETWORK SET FKVTPDOMAIN =:updateFKVTP, VLANNUMBER = :VLANNUMBER,
NETDESCRIPTION = :NETDESCRIPTION,BEGINNINGIP = :BEGINNINGIP,
HOSTS = :HOSTS,DEFAULTGATEWAY = :DEFAULTGATEWAY WHERE NETWORKKEY = :NETWORKKEY"
InsertCommand="INSERT INTO NETWORK.NETWORK (VLANNUMBER,NETDESCRIPTION,BEGINNINGIP,HOSTS,DEFAULTGATEWAY,FKVTPDOMAIN) VALUES (:vlanNet,:descNet,:begIpNet,:hostNet,:defNet,:vtpdomainkey)">
<InsertParameters>
<asp:ControlParameter Name="vlanNet" ControlID="vlanTextbox" />
<asp:ControlParameter Name="descNet" ControlID="descTextbox" />
<asp:ControlParameter Name="begIpNet" ControlID="beginIPTextbox" />
<asp:ControlParameter Name="hostNet" ControlID="hostsTextbox" />
<asp:ControlParameter Name="defNet" ControlID="defaultGatTextBox" />
<asp:ControlParameter Name="vtpdomainkey" ControlID="vtpDomainFKDropDown" />
</InsertParameters>
<UpdateParameters>
<asp:ControlParameter Name="updateFKVTP" ControlID="vtpNameDropDownUpdate" />
</UpdateParameters>
</asp:SqlDataSource>
<asp:GridView
ID="GridView2"
runat="server"
AutoGenerateColumns="False"
DataSourceID="SqlDataSource2"
AllowPaging="True"
AllowSorting="True"
DataKeyNames="NETWORKKEY"
Width="650px"
OnRowUpdating="GridView2_RowUpdating">
<Columns>
<asp:CommandField HeaderText="Options" ShowDeleteButton="True" ShowEditButton="True" />
<asp:TemplateField HeaderText="VTP Domain" SortExpression="VTPNAME">
<EditItemTemplate>
<asp:DropDownList ID="vtpNameDropDownUpdate" runat="server" DataSourceID="SqlDataSource6" DataTextField="VTPNAME" DataValueField="VTPDOMAINKEY">
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("VTPNAME") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
Here's the actual error given:
Could not find control 'vtpNameDropDownUpdate' in ControlParameter 'updateFKVTP'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Could not find control 'vtpNameDropDownUpdate' in ControlParameter 'updateFKVTP'.
Everything works as is supposed to, except the dropDownList. It will NOT find it, I have tried dollar signs, colons,underscore, you name it, to tell it where the control is and no result. They are in the same and they both lay one under the other, just as I posted it here. I got the first row to actually update because I tried the method where you right click on the dropdownlist while running and you "inspect the element" and copy and paste the whole ControlID string into the ControlParameter ControlID. The problem is, there are several rows, so it will only work for the one element I inspected and not all the other ones. Any help would be appreciated and thank you in advance for your time!
-Fernando
The DropDownList is inside The Template Control, so you should find the template control first.In this example template control is in 7th column of Gridview. after find template inside that you can find DropDownList :
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
var index = e.RowIndex;
var dropDownctr= GridView1.Rows[index].Controls[6].FindControl("vtpNameDropDownUpdate")
}