In my c# web app,
I'm trying to invoke an Ajax HoverMenuExtender from Javascript, rather than from hovering over an assigned control.
If I set the TargetControlID of the HoverMenuExtender to a control on my page and hover the mouse over it, the hover menu displays, however, I cannot get it to display by manually invoking it with javascript.
The Javascript I'm currently trying:
popup = $("body").find('HME1');
popup.show();
//popup._popupBehavior.show();
I've stepped through the code so I'm sure popup.show() is being called. But it seems like nothing happens. It seems like .Show isn't really what we want to do, but instead we need to "Invoke" the AjaxExtender somehow.
The HoverMenuExtender:
<cc1:HoverMenuExtender ID="HME1" runat="server" BehaviorID="HME1" TargetControlID="dummyLink" PopupPosition="Top" PopupControlID="PopupMenu"></cc1:HoverMenuExtender>
A dummy link i'm assigning the control ID to:
dummy
The panel i'm trying to display:
<asp:Panel CssClass="popupMenu" ID="PopupMenu"
runat="server">
<asp:LinkButton ID="article" runat="server"
CommandName="Edit" Text="Edit" />
<br />
<asp:LinkButton ID="LinkButton2" runat="server"
CommandName="Delete" Text="Delete" />
</asp:Panel>
Use the following code:
$find("BehaviourID")._popupBehavior.show();
Related
Inside Grid View Image Button is not firing using an ASP.NET Web form. If I will use ASP Button, then working Button and easy adding.
Below is my design Code of grid view Button.
<FooterTemplate>
<asp:ImageButton ID="imgbtnAdd" runat="server" CommandName="AddNew" ImageUrl="~/Imgs/grid_add.png" ToolTip="click here to add" CausesValidation="true" ValidationGroup="Team_involved_directly" />
<%-- <asp:Button ID="Button1" runat="server" Text="Add" CommandName="AddNew" CausesValidation="true" ValidationGroup="Team_involved_directly" ToolTip="click here to add" />--%>
</FooterTemplate>
If I will use above commented button then working fine, but Image Button only giving Issue. And I also used !Page.IsPostBackin my page load.
Have you tried 'OnClick' method for button tag?
I have a dnn site, which has a label and an imagebutton, clicking on which replaces the label with textbox and user can enter their text, once submitted the label will be updated with this text. Now clicking on the imagebutton causes the page to postback, i don't want a postback for this, hence i have placed telerik RadAjaxLoadingPanel control, so the cool loading div gets displayed while processing is going on, but for some reason it's not working, It always throws below error:
Please, see whether wrapping the code block, generating the exception, within RadCodeBlock resolves the error.
Below is the markup of my page: (I tried the wrapping the code with RadScriptBlock and RadCodeBlock, in both case it throws same error as above)
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Default">
</telerik:RadAjaxLoadingPanel>
<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID="RadAjaxLoadingPanel1">
<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
<a class="subscribetoday" href="#">
<strong>Subscribe Today!</strong> <asp:Label ID="lblsubscribemsg" runat="server" Text="12 issues for $14.95"></asp:Label>
<asp:ImageButton ID="imgEditSubscribe" runat="server"
OnClick="imgEditSubscribe_Click" ToolTip='Edit' ImageUrl="~/images/edit.gif" AlternateText='Edit' Visible="false" />
<div id="editsubscribe" runat="server" visible="false">
<asp:TextBox ID="txtSubscribe" runat="server"></asp:TextBox> <asp:ImageButton ID="imgSave" runat="server"
OnClick="imgSave_Click" OnClientClick="return validateSubscribeNote();" ToolTip='Save' ImageUrl="~/images/save.gif" AlternateText='Save' /> <asp:ImageButton ID="imgCancel" runat="server"
OnClick="imgCancel_Click" ToolTip='Cancel' ImageUrl="~/images/cancel.gif" AlternateText='Cancel' />
</div>
<img src="img/prosound-subscribe.png" alt="Subscribe Today!">
</a>
</telerik:RadScriptBlock>
</telerik:RadAjaxPanel>
Can anyone tell me where i am going wrong with this.
The problem is with other server code blocks on the page (<%=%> for example, generally - <% ... %>), not with this concrete piece of code you are trying to AJAX-enable. You can read more here: http://docs.telerik.com/devtools/aspnet-ajax/controls/ajax/radcodeblock-and-radscriptblock
So, you should find the place where those code blocks are used and wrap THEM in a RadCodeBlock controls. It is often scripts that reference controls, e.g.:
<telerik:RadCodeBlock runat="server" ID="RadCodeBlock1">
<script>
function getReference() {
return $find("<%=someControl.ClientID%>");
}
</script>
</telerik:RadCodeBlock>
With DNN, however, I cannot say where these may originate.
Thus, your other option is to use an <asp:UpdatePanel> control to get AJAX requests instead of full postbacks. The native AJAX toolset also offers the <asp:UpdateProgress> control that you can use instead of RadAjaxPanel.
<asp:GridView runat="server" ID="test">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<a href="Aboutus.aspx">
<asp:ImageButton runat="server" ImageUrl="~/image/background-image-top_banner.jpg"
ID="img" /></a>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
When I click on the Image in the gridview, it is not going to Aboutsus page? WHy don't the anchor tag work here?
You might do something like this, to keep things simple
<img src='<%# Eval("ImageSource") %>' />
Or use src="your image location" , if that is static
Dont use image button this will behave as an asp.net button, therefore you have killed your link. Use asp:hyperlink instead
<asp:Hyperlink runat="server" Id="navAbtUs" NavigateUrl="AboutUs.aspx" ImageUrl="~/image/background-image-top_banner.jpg" ID="img" />
I'd also question why you are using a Gridview for this, you will have a column with repeated info.
Try like this chagne image button to simple asp image
<a href="Aboutus.aspx">
<asp:Image runat="server" ImageUrl="~/image/background-image-top_banner.jpg"
ID="img" /></a>
Imagebutton is always creating problem for me,
so i always use link button and giving image between it
like
<asp:linkbutton id="id1" runat="server" ><img src='<Eval("Imagepath" >' /> </asp:linkbutton>
I know this is not appropriate answer, but i have faced problems with image button inside gridview and saw some other guys also face, so i suggested, this is a good alternate of image button
by the way why it is needed to put image button inside linkbutton, you can simply keep asp image if not want to use html image
I have an ajax extender in my aspx page.
I want to make the button do something in code behind when is pushed but my button inside the panel doesn't work.I created another button outside the panel and wrote the same thing to do and is working.
This is my button inside the panel:
<ajax:AccordionPane ID="AccordionPane1" runat="server">
<Header>Adauga titlu</Header>
<Content>
<asp:Panel ID="UserReg" runat="server" DefaultButton="but">
<cc1:Editor ID="Editor1" runat="server" width="500px"/>
<br /><br />
<asp:Button runat="server" ID="but" Text="Adauga Titlu" />
</asp:Panel>
</Content>
</ajax:AccordionPane>
This button is not working but the other button outside is working and they both do the same thing.Can you provide a solution?
Perhaps you are simply missing the OnClick attribute, like this:
<asp:Button runat="server" ID="but" Text="Adauga Titlu" OnClick="but_Click" />
Have you included the Asp ScriptManager?
http://msdn.microsoft.com/en-us/library/system.web.ui.scriptmanager.aspx
I am trying to bypass the ConfirmButtonExtender depending on the value of another field in the page.
Basically, when a user click on my "Cancel" button, I normally display a modalpopup using the confirmbuttonextender and the modalpopupextender to display a dialog box confirming that they wish to cancel any changes they have made and return to the prior screen. If they click Yes, the button's onclick event fires which calls some code in the codebehind and redirects the user to another page. If they click no, it just returns to the same page, with no changes.
However, in some situations, I know that my user is unable to perform any edits (they aren't allowed to) and for those users, I don't want to display the "Are you sure you want to leave you will loose any changes" dialog box.
I've set a hidden checkbox field named "cbAllowEdit" to indicate whether the user is allowed to edit the fields or not.
I was trying to use the technique found at link text to get this working but it just doesn't even seem to be firing the button's onclientclick event at all.
Here is my code.
ASPX & Javascript
<asp:CheckBox ID="cbAllowEdit" runat="server" Checked="true" />
<asp:Button ID="btnCancel" runat="server" CausesValidation="false"
OnClick="btnCancel_Click" Text="Cancel" OnClientClick="disableSubmit();return false;" />
<ajaxToolKit:ConfirmButtonExtender ID="ConfirmButtonExtenderbtnCancel"
runat="server" DisplayModalPopupID="ModalPopupExtenderbtnCancel"
TargetControlID="btnCancel" BehaviorID="ConfirmButtonExtenderbtnCancel" />
<ajaxToolKit:ModalPopupExtender ID="ModalPopupExtenderbtnCancel" runat="server"
BackgroundCssClass="modalBackground" CancelControlID="btnCancelCancel"
OkControlID="btnConfirmCancel" PopupControlID="ConfirmCancelPanel"
TargetControlID="btnCancel" />
<asp:Panel ID="ConfirmCancelPanel" runat="server" CssClass="modalWindow"
Height="200" Width="450">
<p class="confirmMessage">
Are you sure you want to navigate away from this record?
</p>
<div align="center">
<p class="feedbackError">If you have made any changes to the record since the last time
you saved, they will be lost.</p>
<asp:Button ID="btnConfirmCancel" runat="server" Text="Yes" Width="75" />
<asp:Button ID="btnCancelCancel" runat="server" Text="No" Width="75" />
</div>
</asp:Panel>
<script type="text/javascript">
function disableSubmit() {
if (document.getElementById('<%= cbAllowEdit.ClientID %>').checked) {
return checkSubmit();
}
else {
return true;
}
}
function checkSubmit() {
var confirmButton = $find('ConfirmButtonExtenderbtnCancel');
confirmButton._displayConfirmDialog();
}
</script>
Code behind:
/// <summary>
/// Runs when the btnCancel button is clicked.
/// </summary>
protected void btnCancel_Click(object sender, EventArgs e)
{
Page.Response.Redirect("~/Searches/LookupCode/Default.aspx");
}
any ideas on what I am doing wrong?
As Chris said, you don't have to have a ConfirmButtonExtender and ModalPopupExtender (although this looks like a way round the fact that the JavaScript confirm() function is limited to OK and Cancel buttons in its' dialog - noted as a technique for the future :-) )
If you know in your code-behind that the user isn't going to be doing any editing (as evidenced by your cbAllowEdit control), then you should be able to just disable the ConfirmButtonExtender:
ConfirmButtonExtenderbtnCancel.Enabled = false;
Then clicking the Cancel button should take you into your code-behind function without confirmation at all.
EDIT: The ConfirmPopupExtender shouldn't be pointing to the btnCancel. Instead, it should be pointing to a hidden button (this is what the example in the link does).
<asp:Button ID="btnCancel" runat="server" CausesValidation="false"
OnClick="btnCancel_Click" Text="Cancel" OnClientClick="disableSubmit();return false;" />
<!-- This is the Hidden Buttons that you need to add and reference in the ConfirmButtonExtender -->
<asp:Button ID="HiddenButtonConfirm" runat="server" Text="" style="display:none;" />
<asp:Button ID="HiddenButtonModal" runat="server" Text="" style="display:none;" />
<ajaxToolKit:ConfirmButtonExtender ID="ConfirmButtonExtenderbtnCancel"
runat="server" DisplayModalPopupID="ModalPopupExtenderbtnCancel"
TargetControlID="HiddenButtonConfirm" BehaviorID="ConfirmButtonExtenderbtnCancel" />
<!-- You'll also want the ModalPopup to point to a seperate hidden button. -->
<ajaxToolKit:ModalPopupExtender ID="ModalPopupExtenderbtnCancel" runat="server"
BackgroundCssClass="modalBackground" CancelControlID="btnCancelCancel"
OkControlID="btnConfirmCancel" PopupControlID="ConfirmCancelPanel"
TargetControlID="HiddenButtonModal" />
This javascript might work:
var confirmbtn = $find('ConfirmButtonExtenderID');
confirmbtn.enabled =false;
//ConfirmButtonExtenderID needs to be the name of your ConfirmButtonExtender ID [:$]