Anybody help me to resolve this issue ?
I am displaying one grid on hover of linkbutton using AJAX hovermenu extender.
But when page is loading first time or on postback, that grid is displaying.
Below is the code:
<asp:LinkButton ID="lnkItm" runat="server" Text="Click"></asp:LinkButton>
<AjaxToolKit:HoverMenuExtender ID="hme2" runat="Server" TargetControlID="lnkItm"
PopupControlID="PopupMenu" HoverCssClass="popupHover" PopupPosition="Right" OffsetX="0"
OffsetY="0" PopDelay="50" />
<asp:Panel CssClass="PopupMenu" ID="PopupMenu" runat="server">
<asp:GridView ID="grd" runat="server" Width="100px" AutoGenerateColumns="False">
<Columns>
...
</Columns>
</asp:GridView>
</asp:Panel>
Please let me know how to resolve this issue.
Add this.It will hide the popup when the page loads.
<style type="text/css">
.PopupMenu
{
display: none;
}
</style>
Related
I have a dynamic gridview, want vertical scrolling functionality and disable paging altogether
You can wrap the gridview inside a div and set the height of the div. Like
<div style="overflow: auto; width: 100%;height:200px">
--your Gridview
</div>
It worked for me ,where the paging is off for the Gridview.
in gridview PageIndexChanging you must change PageSize to big number size
gridview.PageSize = 100
or more than 100
for vertical scrolling use java
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="up" runat="server">
<ContentTemplate>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="ContactName" HeaderText="Contact Name" />
<asp:BoundField DataField="City" HeaderText="City" />
<asp:BoundField DataField="Country" HeaderText="Country" />
</Columns>
</asp:GridView>
<asp:Button ID="Button1" runat="server" Text="Refresh" />
</ContentTemplate>
</asp:UpdatePanel>
<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script src="Scripts/ScrollableGridViewPlugin_ASP.NetAJAXmin.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#<%=GridView1.ClientID %>').Scrollable({
ScrollHeight: 300,
IsInUpdatePanel: true
});
});
</script>
I am sorry I am repeating this question. Rather, I am having to repeat it. The last time I posted this, I dint get an answer. I have googled for more than 3 hrs, dint find an answer. Heres the html for the linkbutton and the modal popup. The link button is inside/on a tab panel and auto postback is set to true.
<asp:LinkButton ID="lnkAddNewAddress" runat="server" OnClick="lnkAddNewAddress_Click">Click Here To Add New Address</asp:LinkButton>
<asp:ModalPopupExtender ID="lnkAddNewAddress_ModalPopupExtender" runat="server" BackgroundCssClass="modalBackground"
DynamicServicePath="" Enabled="True" PopupControlID="pnlMyAddressBook" TargetControlID="lnkAddNewAddress"
ViewStateMode="Enabled" >
</asp:ModalPopupExtender>
I want the clickevent of the linkbutton to fire which is not happening. However clicking on the link does open the modal popup extender (which is also something I want)... How do I get into the click event. I know that a postback is being avoided here because of the modal popup probably...but I dont the solution for it....
The code on save button:
if(hdnfld.Value.ToString()!=null)
{
if(hdnfld.Value.ToString()=="Save")
{
SaveNewAddress();
}
else
{
UpdateAddress();
}
<%# Page StylesheetTheme="" Title="" Language="C#" MasterPageFile="~/Site.Master"
AutoEventWireup="true" CodeBehind="frmMyAccountMyProfile.aspx.cs" Inherits="WebApplication1.frmMyAccountMyProfile" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
<script type="text/javascript">
function CheckType(type)
{
document.getElementById("hdnfld").value = type;
alert(document.getElementById("hdnfld").value);
return false;
}
</script>
<link href="Styles/myStyleSheet.css" rel="stylesheet" type="text/css" />
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<div class="divwrap">
<table style="width: 100%; margin-right: 0px;">
<tr>.........
<td>
<asp:LinkButton ID="lnkAddNewAddress" runat="server" OnClientClick="return CheckType('Save');">Click Here To Add New Address</asp:LinkButton>
<asp:HiddenField ID="hdnfld" runat="server" />
<asp:ModalPopupExtender ID="lnkAddNewAddress_ModalPopupExtender" runat="server" BackgroundCssClass="modalBackground" DynamicServicePath="" Enabled="True" PopupControlID="pnlMyAddressBook" TargetControlID="lnkAddNewAddress"
ViewStateMode="Enabled">
</asp:ModalPopupExtender>
...........
<asp:Button ID="btnEdit" runat="server" CssClass="roundcorner btn" OnClick="btnEdit_Click" OnClientClick="return CheckType('Edit');" Text="Edit" />
<asp:Panel ID="pnlMyAddressBook" runat="server" BackColor="White" CssClass="roundcorner">
you can use hidden field instead of viewstate, if you really want to retain some value at code behind. You can access hidden field at client side as well as in code behind too.
<asp:LinkButton ID="lnkAddNewAddress" runat="server" OnClientClick="return CheckType('save');">Click Here To Add New Address</asp:LinkButton>
<asp:HiddenField ID="hdf_type" runat="server" />
Javascript code
function CheckType(type) {
document.getElementById("hdf_type").value = type;
return false;
}
Access value in code behind when clicked on save button, and perform your action save or update according to value in hidden field.
hdf_type.Value.ToString();
MORE HELP FOR YOU
HTML FILE SHOULD LOOK LIKE THIS
below i'm posting the whole code which is working fine for me.
<head runat="server">
<title></title>
<script type="text/javascript">
function CheckType(type) {
document.getElementById("hdf_type").value = type;
alert(document.getElementById("hdf_type").value);
return false;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<asp:LinkButton ID="lnkAddNewAddress" runat="server" OnClientClick="return CheckType('save');">Click Here To Add New Address</asp:LinkButton>
<asp:Button ID="btn" runat="server" OnClientClick="return CheckType('edit');" Text="Click Here To Add New Address" />
<asp:ModalPopupExtender ID="lnkAddNewAddress_ModalPopupExtender" runat="server" BackgroundCssClass="modalBackground"
DynamicServicePath="" Enabled="True" PopupControlID="pnlMyAddressBook" TargetControlID="lnkAddNewAddress"
ViewStateMode="Enabled">
</asp:ModalPopupExtender>
<div id="pnlMyAddressBook" style="height: 100px; width: 100px; display: none; background-color: Gray">
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /><br />
</div>
<asp:HiddenField ID="hdf_type" runat="server" />
</div>
</form>
getting value at code behind:
Try this:
<asp:LinkButton ID="lnkAddNewAddress" runat="server" OnClick="lnkAddNewAddress_Click">Click Here To Add New Address</asp:LinkButton>
<asp:ModalPopupExtender ID="lnkAddNewAddress_ModalPopupExtender" runat="server" BackgroundCssClass="modalBackground"
DynamicServicePath="" Enabled="True" PopupControlID="pnlMyAddressBook" TargetControlID="btnHidden">
</asp:ModalPopupExtender>
<asp:Button ID="btnHidden" runat="server" style="Display:none;" Text="Button"/>
In Code behind:
protected void lnkAddNewAddress_Click(object sender, EventArgs e)
{
lnkAddNewAddress_ModalPopupExtender.Show();
}
I am using a datalist control in which i have a div and some other asp controls.
I have an edit button in it. If I click on edit button, I want to redirect user to another page on which I have some controls and I want information to be filled up in those controls depending upon the button I have clicked in previous page.
Here is the datalist code:
<asp:DataList ID="DataList1" runat="server" DataKeyField="ID" RepeatColumns="2" RepeatDirection="Horizontal" RepeatLayout="Table">
<ItemTemplate>
<div><br /><br /><br />
<div style="background-color:Silver;height: auto; display:block;" >
<div id="threadPostLeftDiv" style="width:auto; border-style:solid; border-width:2px; border-color:Black;border-right-color:White;" >
<asp:Image runat="server" ID="ImagePreview1" style="margin-right:5px; " ImageUrl='<%# Eval("imageurl") %>' Height="100px" Width="100px" BorderStyle="None" />
</div>
<div id="threadPostRightDiv" style=" border-style:solid; border-width:2px;margin-left:-15px; border-color:Black;border-left-color:White;">
<asp:Label ID="txtHeadline1" CssClass="inputprev" style=" font-size:medium; font-weight:bolder;" Text='<%# Eval("subtitle") %>' Enabled="false"
placeholder="Headline" runat="server"></asp:Label>
<br />
<asp:Textbox ID="txtDescription1" CssClass="inputprevdesc1" Text='<%# Eval("descriptions") %>'
Enabled="false" BackColor="Silver" Rows="3" TextMode="MultiLine" placeholder="Description" runat="server"></asp:Textbox><br />
<br />
<asp:Label ID="txtOfferHeadline1" Text='<%# Eval("title") %>' Enabled="false" CssClass="inputprev1"
placeholder="Offer Headline" runat="server"></asp:Label>
<br />
</div>
</div>
<div style=" float: right;margin-right:10px; ">
<button id="btnEdit" class="css3button1" onserverclick="btnEdit_Click" runat="server">Edit</button>
</div>
</div>
</asp:DataList>
Please help me in acheiving my goal,give me the code behind file and what events to triggers.
Thank you.
Well that can be easily achived by doing the following things
bind 'btnEdit' commandargument with the id
<button id="btnEdit" class="css3button1" onserverclick="btnEdit_Click" runat="server" CommandArgument='<%# Eval("ID") %>' >Edit</button>
in btnEdit_Click event do the following
Button bt = (Button)sender;
string recordid = bt.CommandArgument;
Response.Redirect("editrecordno.aspx?recordid="+recordid,true);
in editrecordno.aspx page request the querystring and do the need full.
in Button_Click event you shoul redirect to another page with QueryString paramater
Replace your edit <button> with this code line
<asp:Button ID="Button1" PostBackUrl='DataEdit.aspx?id=<%# Eval("id") %>' runat="server" Text="Edit" />
In DataEdit.aspx put your FormView with DefaultMode=Edit
Then Add new QueryString Parameter in your DataSource
I converted html button to link button and fired onRowCOmmand event and I got my solution.
I have a simple ASP.NET form that Im using to learn some AJAX controls.
My code is:
<form id="form1" runat="server">
<ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</ajaxToolkit:ToolkitScriptManager>
<div>
<div style="height: 300px; width: 250px; float: left; padding: 5px;">
<asp:Panel ID="Panel1" runat="server" Width="250px">
<asp:Panel ID="Panel2" runat="server" Width="40%" Height="20%" BorderWidth="1px"
BorderStyle="Solid" BorderColor="black">
Drag This Panel
</asp:Panel>
</asp:Panel>
</div>
</div>
<ajaxToolkit:DragPanelExtender ID="Panel1_DragPanelExtender" BehaviorID="DragP1"
DragHandleID="Panel1" TargetControlID="Panel1" runat="server">
</ajaxToolkit:DragPanelExtender>
</form>
My problem is that when I drag the Panel it doesn't stay where I leave it. It immediately moves back. shouldn't it stay where I leave it. I appreciate if I postback it will move back but I'm staying on the page incurring no new events.
Is this right?
Mike
I never used drag panel but I think there is something wrong with your markup.
Both the DragHandleID and TargetControlID are set to Panel1 which is wrong.
DragHandleID="Panel1" TargetControlID="Panel1"
According to the example on the Ajax site it's markup is http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/DragPanel/DragPanel.aspx
<ajaxToolkit:DragPanelExtender ID="DPE1" runat="server"
TargetControlID="Panel3"
DragHandleID="Panel4" />
In the above markup they have used different panels for the targetControlID and DragHandleID
so you should update your markup as
<ajaxToolkit:DragPanelExtender ID="Panel1_DragPanelExtender" BehaviorID="DragP1"
DragHandleID="Panel1" TargetControlID="Panel2" runat="server">
</ajaxToolkit:DragPanelExtender>
For the following code
<asp:GridView runat="server" ID="gvCustomers" ...
...
<Columns>
<asp:TemplateField>
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<asp:ImageButton runat="server" ID="ITimgExpand" ImageUrl="~/Images/Common/expand.gif" CommandName="Select" />
</ItemTemplate>
</asp:TemplateField>
...
<asp:TemplateField>
<ItemTemplate>
</td></tr>
<tr>
<td colspan="3">
<div id="document_<%# Eval("RENTER_ID") %>" style="margin:10; display: none; position: relative">
<asp:GridView ID="gvDocuments" runat="server" ...
...
How does one expand/collapse div which includes nested GridView while clicking ITimgExpand ImageButton?
Add the following javascript function:
function togglePanel(divId){
if (document.getElementById){
var container = document.getElementById(divId);
if (container.style.display =='none'){
container.style.display = 'block';
}else{
container.style.display ='none';
}
}
}
Then have your ImageButton call the function passing the ID of the
<asp:imagebutton id="ImgBtn" runat="server" onclientclick="togglePanel('document_<%# Eval("RENTER_ID") %>')" />
Use can use the Jquery hide function to do this.
http://jqueryui.com/demos/hide/#default