Xamarin iOS Webview auto execute OnClientClick() - vb.net

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.

Related

How do I display a modalpopupextender from a server side button click?

I have an Ajax ModalPopUpExtender which works fine when launched by the target control, but what I want to do is launch it from a server side Button_Click event in VB.
This is because I want to check some variables before launching the ModalPopUpExtender.
I have tried the .show method which works fine on an initial PageLoad event when there is no post back, but the method won't work from an asp:button's onclick event or from a post back event.
I have given the ModalPopUpExtender a dummy button to target as you can't run one without the TargetControlID being set. The dummy control is visible.
As the .show method works on a PageLoad event I know the ModalPopUpExtender is set up correctly, but what could be stopping it from running from a server-side event?
Here's my code:
<ajax:ModalPopupExtender
ID="mp1"
runat="server"
PopupControlID="Panel1"
TargetControlID="btnShowPopUp" CancelControlID="btnClose"
BackgroundCssClass="modalBackground">
</ajax:ModalPopupExtender>
Sub btnShow_Click(ByVal sender As Object, ByVal e As EventArgs)
if myVariable = 1 then
mp1.show
End if
End Sub
After searching on more permutations of my question I finally found the answer in an existing answer on the site. The target control has to be a hidden field object, not another button.
The full answer is at:
ASP.NET: ModalPopupExtender prevents button click event from firing

MessageBox launches but does not display

I'm working on a project and I am using a button to show a message box with sample data.
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
MessageBox.Show("hi")
End Sub
Simple enough.
However, when you click the button, I hear the sound that the MessageBox has launched, but the form is never displayed.
I know it has launched because if I try to do anything after clicking the button, I'm locked out. I have to press enter to acknowledge the MessageBox before I can continue.
This project used to display the MessageBox, but it has stopped.
I've tried several different areas in code, but whenever I show a MessageBox, I get the same results. Any ideas on what I have done?
never mind, I solved it.
there was a sub that was rendering a picturebox every time the form_paint was called. It overwrote the messagebox on the screen.

Visual Basic - URL showing when click on a link

Just wonder if you could help.
Basically I have a little project to finish, I have created a web browser with VB.NET, when I navigate let's say Google.com, I click to open a link on Google's website and it opens in a new page which is fine but the TextBox on my project (where the URL goes) does not appear any URL to which page/website I've gone to.
Can someone help me on this please?
Thank you so much!
Marco
You can do this by adding a handle to the Navigated event of the WebBrowser.
Private Sub WebBrowser1_Navigated(sender As System.Object, e As System.Windows.Forms.WebBrowserNavigatedEventArgs) Handles WebBrowser1.Navigated
Me.TextBox1.Text = Me.WebBrowser1.Url.ToString()
End Sub
The WebBrowser.Navigated Event is raised when the control has navigated to a new document and has begun loading it.

VB.Net WebKitBrowser Enter key issue

I'm programming with vb.net 2012 and I'm having an issue with the WebKit.Net framework.
After my webkitbrowser object has loaded a page, I enter in login credentials, now the tab button gets hooked fine but when I hit enter (like people normally do on websites to login rather than actually hitting the login button) it keeps focus on another form object (tab index 0) and hits enter on that, it doesn't hook the enter button to the webkitbrowser.
I have added the following but it hasn't worked.
Private Sub WebKitBrowser2_MouseClick(sender As Object, e As MouseEventArgs) Handles WebKitBrowser2.MouseClick
Me.WebKitBrowser2.Focus()
End Sub
I'm hoping someone has a solution to this issue?

asp image button click event with JQuery Mobile

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" />