Is it possible to add a hyperlink to ASP LinkButton - c#

I have a link button that I want to put a hyperlink to that a popup div is called when the button is clicked.
The asp linkbutton is declared as such:
<TD Class="SpreadSheet"<ASP:LinkButtonID="lbtnViewUsers_Edit" Text="Edit" Runat="Server" onclick="#Upload"/></TD>
and the popup to be called is
<div id="Upload" class="overlay" runat="server">
<div class="popup">
<h2>Edit User &nbsp </h2>
<a class="close" href="#">×</a>
<div class="content">
<!-- content -->
</div>
</div>
</div>
Is there a way to put a sort of href = "#Upload" to the link button?

What you are looking for is a model pop. Asp.net Ajax tool kit has one, you can learn more about it at here . I created a simple sample of how to use this model pop-up. Bear in mind you first have to add the tool kit to your asp.net project (you can use nuget package manager for this) and register the control to page using
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
use the properties of Model pop extender to show and save your per record data.
<asp:Panel ID="pnlpopup" runat="server" Width="400px">
<asp:Panel ID="headerPanel" runat="server">Header text Here </asp:Panel>
<div class="form-group">
<asp:Label ID="Label1" runat="server" Text="lable 1"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</div>
<div class="form-group">
<asp:Button ID="btnSave" runat="server" OnClick="btnSave_Click" Text="Save" />
<asp:Button ID="btnCancel" runat="server" Text="Cancel" />
</div>
</asp:Panel>
<div class="form-group">
Other data values here
<asp:LinkButton ID="lbEdit" runat="server">Edit</asp:LinkButton>
</div>

Related

Open a modal with a text area to fill and a text area loading some content from the page

I'm working with WebForms and I need to create a modal, or anything like this on click on a button to reject an item, the modal should show the item ID and a text area to fill up with the reason why this item will be rejected.
I'm on it for about one week and I can't figure out how could I get the item id and put it on the modal.
I've never used WebForms before, and I'm not finding anything that helps me.
this is my modal code:
<asp:Panel ID="pnlMotivoRejeitarTitulo" runat="server" Width="610px">
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:Button runat="server" ID="btnShowModalPopup2" Style="display: none" />
<ajaxToolkit:ModalPopupExtender ID="modalRejeitarTitulo" runat="server" TargetControlID="btnShowModalPopup2"
PopupControlID="divPopUp2" BackgroundCssClass="popUpStyle" PopupDragHandleControlID="panelDragHandle"
DropShadow="true" RepositionMode="RepositionOnWindowResize" />
<div class="popUpStyle" id="divPopUp2" style="display: none;">
<div style="width: 600px; max-height: 160px;">
<asp:Panel runat="Server" ID="panel1" CssClass="drag01">
<asp:Label ID="lblTituloModal" runat="server" Text="EXCLUIR TÍTULO?"></asp:Label>
<br />
</asp:Panel>
<div class="subtitulo">
<asp:Label ID="lblMensagemOrigemAgregadoMiudo" runat="server" Text=""></asp:Label>
</div>
<br />
<asp:Panel ID="pnlRejeitarTitulo" runat="server" Width="550px" BackColor="#CCCCCC"
CssClass="centralizaPanel" BorderStyle="Outset">
<div style="padding-top: 10px;">
<div class="campo">
<div class="label_formulario8">
<asp:Label ID="lblId" runat="server" Text="ID: "></asp:Label>
</div>
<asp:TextBox ID="txtId" runat="server" Width="100px" ReadOnly="true"></asp:TextBox>
</div>
<div class="campo">
<div class="label_formulario8">
<asp:Label ID="Label3" runat="server" Text="Descrição: "></asp:Label>
</div>
<asp:TextBox ID="txtDescricao" runat="server" Width="300px"></asp:TextBox>
</div>
<br />
</div>
<div class="centraliza_botao">
<asp:Button ID="btnConfirmarExcluirTitulo" runat="server" Text="Confirmar" CssClass="btn btn-primary" OnClick="btnConfirmarExcluirTitulo_Click"
Style="height: 31px" CausesValidation="false" />
<asp:Button ID="btnFecharExcluirTitulo" runat="server" Text="Fechar" CssClass="btn btn-warning"
Style="height: 31px" CausesValidation="false" OnClick="btnFecharExcluirTitulo_Click" />
</div>
<br />
</asp:Panel>
</div>
<br />
<br />
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
on txtId must appear the item ID, I've tried to use JS getting the id of the rendered input, but it take so long to render, so JS does not work.
I figured out that I had to fill all the fields before call the method that shows the modal dialog.
I was thinking like jQuery but it does work like that on WebForms

Update panel on Telerik control

In my asp.net application there are several dropdown and textbox control which creates dynamically. So on select of dropdown while data is being fetched I want to show update progress on div. Also I dont want to post back call so whole page should not be refreshed.
Here is my code
<div class="col-md-2">
<div class="filter-section">
<table>
<tr>
<td>
<asp:Panel ID="ControlsParent" ViewStateMode="Enabled" ClientIDMode="Static" runat="server"></asp:Panel>
</td>
</tr>
<tr>
<td>
<asp:Button ID="BtnShowReport" runat="server" ClientIDMode="Static" CssClass="btn btn-primary btn-block" Text="Show Report" OnClick="BtnShowReport_Click" />
</td>
</tr>
</table>
</div>
</div>
I am new to Telerik so dont have idea to use.
Put the code insiode the Update Panel, I am using Simple asp and haven't used Telerik in following:
// you code codes here
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress DynamicLayout="true" ID="upProgSearch" DisplayAfter="1500" runat="server" >
<ProgressTemplate>
<div id="progressBackgroundFilter"></div>
<div id="processMessage" style="width:100px;">
<asp:Image ID="Image1" ImageUrl="~/images/Loading.gif" runat="server" />
</div>
</ProgressTemplate>
</asp:UpdateProgress>
for preventng auto postback use <triggers> tags in update panel and use <asp:AsyncPostBackTrigger> and specify the event name that causes postback and you don't want .

How to preview image before upload on ASP.NET master page content placeholder

How do i preview image before upload on asp.net masterpage content placeholder using asp.net controls? I would prefer it to be automatically displayed after choosing a image from the file upload control.
Here's my code:
UploadPicture.aspx
<asp:Content ID="Content1" ContentPlaceHolderID="content" runat="server">
<div class="container">
<div class="row">
<div class="col-sm-3">
<asp:FileUpload ID="FileUpload1" runat="server"/>
<asp:Image ID="image" runat="server"/>
<asp:TextBox ID="textBox1" runat="server"></asp:TextBox>
<asp:Button ID="upload" runat="server" OnClick="upload_Click" Text="Upload" />
<asp:Label ID="lb_msg" runat="server"></asp:Label>
</div>
</div>
</div>
Thanks!
The only way to preview the image before actual post to the server is using javascript file api. This task is not about serverside controls. You can read here about js fileapi.

Call another ASP Page dynamically with different Parameters in ASP.NET C#

I want to call another ASP Page and pass a parameter (entry.ID).
I have a Master-Page Global.master like this (I will only post a part of code):
<body>
<div id="global" style="height:2000px;">
<form runat="server" id="globalForm">
<div id="body">
<asp:ContentPlaceHolder ID="mainContentPlaceHolder" runat="server">
<div id="mainContent">
</div>
</asp:ContentPlaceHolder>
</div>
</form>
</div>
and a Default.aspx Page which uses the Master-Page:
<asp:Content ID="Content1" ContentPlaceHolderID="mainContentPlaceHolder" runat="Server">
<div id="mainContent">
<% ICollection<Database.Blogentry> entries;
entries = Database.BlogentryDBO.Instance.getAllBlogentries();
foreach (Database.Blogentry entry in entries) { %>
<div class="blogEntryBody">
<div class="blogEntryText">
<%= entry.Content %>
</div>
</div>
<div class="blogEntryFooter">
<span class="blogEntryView">
<%--CALL HERE ANOTHER PAGE WITH A BUTTON AND PASS THE PARAMETER entry.ID-->
</span>
</div>
<%
}
%>
</div>
I already tried it with
<label visible="false" id="LabelEntryId" name="LabelEntryId"><%= entry.ID %></label>
<asp:button ID="Button2" runat="server" class="buttonBlogEntry" text="view more ..." onclick="viewEntireBlog_onclick" CommandArgument='<%# Eval("LabelEntryId")%>' />
but I don't have a CommandEventArgs element in the onClick method but only a EventArgs element so I can't access my CommandArgument?!
And using
<input runat="server" type="text" id="LabelEntryId" value="<%= entry.ID %>" visible="false"/>
and then accessing the input-element in the code-behind isn't possible either, because i have more than one LabelEntryId-Input because of the loop.
Another idea was to do something like this
<asp:button ID="Button1" runat="server" class="buttonBlogEntry" text="view more ..." onclick="<%= Response.Redirect("BlogEntrySortedByCategory.aspx?entryID=" + entry.ID); %>"/>
but I don't know how to do that...
Can you help me please?
have you tried with a standard a tag?
<a href='/someotherpage.aspx?entryid=<%= entry.Id %>'>View more</a>

ASP.NET events not firing in <div> Tag

I have a tags that when you hover over another div tag containing the login and password form appears. But for some reasons the event is not firing.
I put the same control outside of the hover and it can be fired.
At first i thought it was because of a drag-and-drop problem because my div could be dragged and placed in the textbox for the website link so i disabled drag-and-drop on my page but the problem doesn't go away.
The mouse cursor changes to the human finger cursor too when I hover over the div.
Here is the code on masterpage where nav-item is the cause:
<div class="brick1" style="width: 33%">
<a href="" class="nav-item">
<div class="nav-hover">
<div class="loginbrick">
<asp:ContentPlaceHolder ID="LoginPlaceHolder" runat="server">
</asp:ContentPlaceHolder>
</div>
</div>
<i class="li_bulb"></i><span>Welcome, Hover over to login</span>
</a>
</div>
Default.aspx's contentplaceholder:
<asp:Content ID="Content4" ContentPlaceHolderID="LoginPlaceHolder" runat="Server">
<form id="AnonymousForm" runat="server">
<asp:Label ID="Label1" runat="server" Text="UserName: " CssClass="aspTextView"> </asp:Label>
<asp:TextBox ID="tbUserName" runat="server" CssClass="aspTextBox" OnTextChanged="tbUserName_TextChanged"></asp:TextBox>
<br />
<asp:Label ID="Label2" runat="server" Text="Password: " CssClass="aspTextView"></asp:Label>
<asp:TextBox ID="tb_Password" runat="server" CssClass="aspTextBox"></asp:TextBox>
<br />
<asp:Button ID="Button1" runat="server" Text="Login" OnClick="Button1_Click" />
</form>
</asp:Content>
You are enclosing div.nav-hover and div.loginbrick in a hyperlink. Try what happens when you remove that.
in your html brow > brick1 in which your login form is placed.
On brick1 click all event are prevented..
So try to put your form out side brick1.
I am sure your button event is not fire bCoz of js
Checkout you have not added multiple form tag actually we have same problem. and i found issue was because of multiple form in same page.

Categories

Resources