I have been working on a site in VB.NET and JQM - and all has been going OK.
Now, I am trying to include a standard Image button using a tag such as:
<asp:ImageButton ID="btnYear" runat="server" ImageUrl="~/images/buttons/year_btn.gif" />
and in the VB code behind file there is a click event similar to the following:
Private Sub btnYear_Click(sender As Object, e As System.Web.UI.ImageClickEventArgs) Handles btnYear.Click
Session("TimeFrame") = "YEAR"
*do other code*
End Sub
When I click the Image Button and trace the code - all the code in the page events in the code behind file fire (page load, page prerender, etc) - but the click event for the image button never fires.
If I replace the Image button with a standard asp:Button and do all the same - then the click event in the code behind fires just fine! Is it not possible to use an ASP ImageButton within a JQM page and hold a click event in the VB Code behind file?
EDIT
Ok much appreciation to andleer for his response - but it brings a new scenario (problem) with my page to light, also concerning these ImageButtons.
I have the ImageButton controls contained within a user control. My page is a single ASPX file with multiple
<div data-role="page">
elemenst in it, each with its own ID ("page1", "page2", "page3", etc) - following the standard usage of JQM's multi-page functionality. Each "page" section contains an instance of the user control that contains the Image buttons. This all works well, with one problem - when the user navigates away from the default "page1" to any other "page" and clicks one of the image buttons, the code fires, the page reloads - and lands the user back on the default page - "page1".
This is no good - I needed a way to allow the user to fire the button and reload the page and stay on the "page" element they were viewing - JQM accomplishes these multiple pages using hash tags in the URL - so I found a line of code that I added to the page's load event which read:
`Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Me.Form.Attributes("onsubmit") = "this.action+=top.location.hash;"
End Sub`
I was originally using radio buttons on my user control - which JQM was "skinning" so they appeard as buttons - and with this one line in the Page_Load event, a user could click a radio button on any "page" element and the code behind the radio buttons would fire and the page would reload with the user back on the same "page" element they clicked from - not so replacing the radio button with Image Buttons - when I add that line of code to the Page_Load event, the ImageButton controls completely cease to function - when I click the the code in their click even in the code behind does not fire - nor do any of the page level events such as Page_Load or Page_PreRender - clicking them now does absolutely nothing....
Any thoughts on this?
A new answer to address the second part of your question:
I have found that asp.net web forms simply doesn't work with jQuery Mobile multi page scenarios. Web forms requires all web controls to reside within a single <form /> element that needs to span all jQuery Mobile ("virtual") pages. This is in direct conflict with jQuery Mobile's need to have <form /> elements within each sub page for proper rendering and post packs.
Consider MVC instead.
The issue is that an <asp:ImageButton /> renders as a <input type="image" /> which is hidden by jQuery Mobile. Add a data-role="none" to you ImageButton which will cause jQuery Mobile to render the control as is.
<asp:ImageButton id="MyButton" runat="server" data-role="none" />
Related
First, I sorry for my bad English to explain to everybody. :((
I have a problem. My Xamarin iOS using WebView in loading my Website created in VB.Net
I have 1 delete button and when i click on it, it shows confirm dialog for the user confirmation before deleting, but when I click Ok it is not working and when I go back to the previous page and come back to same page again and click Delete button confirmation Dialog is displayed but task is auto-executed even when I have not chosen anything.
My aspx code:
<asp:Button ID="Button1" runat="server" Text="Delete" OnClientClick="return confirm('Are you sure you want delete');" ommandName="Delete" CommandArgument="" />
My aspx.vb
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
// Do the logic delete on DB
Master.Redirect("previousPage.aspx")
End Sub
How I can fix it.
I resolve this issue.
I don't know why this issue going, it's will have a problem with all confirm dialog.
I using a Jquery Confirm Library https://craftpip.github.io/jquery-confirm/ replace all confirm dialog with javascript and it works perfect.
I want to start p:poll when user click on upload button on p:fileUpload
NOTE: when i put manually onclick script into the button using browser elements works fine. i want to do that same
Basically when the user clicks on the upload button the onstart event is fired so you can use it.
<p:fileUpload onstart="PF('pollWV').start()" />
I have a small VB winforms app with a forward and back button. These two buttons allow you to cycle through numerous "pages". I would like to display the next and previous page title in tooltips when the mouse hovers over the buttons(arrows).
Example, when hovering over the left arrow button, I would like to display the name previous page.
So page 1 is applications, page 2 is emails, page 3 is pdf documents etc...
I added the tooltip property from the toolbox in Visual Studios, but it only allows me to type a single item as opposed to scrolling through my list of pages and determining what the previous page name is and displaying it.
The page or form itselt doesn't change, and neither do the buttons, just a panel contained inside the form has the "pages" that change, so I need to be able to write a function that figures out which page is previous and which page is next on the fly when mousehovers the buttons in question... Then returns the data so I can display it in the tooltip.
Better Question;
How can I pass any variable into a tooltip instead of setting it as a property.
Given a tooltip named ToolTip1, then you can set variable text to a control, like this:
Dim myToolTipText = "Dummy text"
ToolTip1.SetToolTip(Me.Button1, myToolTipText)
I wanted to assign the button's text to the tooltip title at runtime. I used the following code:
Private Sub ToolTip1_Popup(sender As Object, e As System.Windows.Forms.PopupEventArgs) _
Handles ToolTip1.Popup
ToolTip1.ToolTipTitle = e.AssociatedControl.Text
End Sub
I have a page with a viewPanel and a dialog. When an item in the viewPanel is clicked, the dialog opens, prompting the user to make changes to that item, and offering them the option to generate a report of the item in PDF format.
At first, I tried putting the PDF creation onto a button, as described here: http://www.eknori.de/2011-10-25/xpages-to-pdf-with-itext/ However, whenever the button is pressed, I get a "NotFoundError: DOM Exception 8" which seems to stem from the dojo JS. So currently I have an alternative whereby the button simply sets some sessionScope variables and opens a pdf.xsp XPage, where the variables are read back and the PDF is created.
The PDF gets created correctly, but it also means that the page that the user is on won't be refreshed to display their new change in the viewPanel. I've tried adding page redirects at the bottom of the XPage which creates the PDF, but with no luck.
So, how can I create a PDF and prompt a user to download it, but also refresh the page that they are currently on?
Are you isseuing an partial refresh on the button to hide your dialog and to execute the code for pdf generation? If so you I think that there is your problem. What you could do is to do a partial refresh on the onClose() method of the dialog to refresh the viewpanel. In the clientside onunload method you could open a so called xAgent which renders the pdf for you in a new window (window.open(pdf.xsp?docid=xxx). Take a look here: NotesIn9: 039 Creating PDF’s with XPages Part 2
Of cours the problem with this approach is that when you have a button / image in yoru viewpanel row that displays if the report has been created is not shown because the xagent runs after the / during the time the viewpanel row is being refreshed.
I have markup in this format:-
<asp:UpdatePanel runat="server" id="UpdatePanelList" UpdateMode="conditional">
<ContentTemplate>
<asp:ListView></asp:ListView>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel runat="server" ID="UpdatePanelMain" UpdateMode="Conditional">
<ContentTemplate />
</asp:UpdatePanel>
In this update panel, if the record from the database can be found a DataGrid control (with label and dropdown controls) should be displayed. If not a HtmlGenericControl DIV Control should be displayed with a relevant message asking the user to create the record. Both these controls are dynamically created which are populated with custom-built classes using "output" functions like "ToString".
If I test the operation with several successive DataGrid controls populating the UpdatePanel, this works fine. Similarily, the HtmlGenericControl DIV populates as expected also in multiple succession.
However, when I test the other control type to populate the UpdatePanel, this works on the first instance, but any additional postbacks to populate the UpdatePanel fail and a dialogue box prompts:
Failed to load viewstate. The control tree into which viewstate is being
loaded must match the control tree that was used to save viewstate during
the previous request. For example, when adding controls dynamically, the
controls added during a post-back must match the type and position of the
controls added during the initial request.
I was led to believe the UpdatePanel Control takes control of the viewstate in this instance for dynamic controls.
How do I restore the viewstate to allow multiple types of controls to be
displayed in the same UpdatePanel?
Thanks.
Restore all the dynamic controls (save the information to do so to the ViewState, or whatever is determined appropriate) in the same hierarchy order as the last page was generated in the "Init" or "Load" life-cycle events. This is the same requirement for normal and asynchronous post-backs in ASP.NET WebForms.
The controls must be added -- to match the control hierarchy -- and then removed after the "Load" event.
Refer to:
DynamicControlsPlaceholder, which is a pre-made control to help with this. It also discusses how it works.
Dynamic Loading of ASP NET User Controls.