WebBrowser control does not complete loading when javascript:void(0) called - c#

I have an application in C# which uses a WebBrowser control.
On one page the user can click a button to process some information and navigate to a new page. The issue is that when the user clicks this button the WebBrowser just seems to stop.
I handle the Navigating, Navigated and DocumentCompleted events in my code and I see the Navigating event but then nothing else.
This is the HTML for the button being clicked:
<div class="right button-wrapper">
<div class="clearfix right">
<span id="nextbutton"
class="button-link button-link btn-reg btn-blue-reg">
<span class="hasHover"><a id="btnPay"
href="javascript:void(0);" class="buttons">Next:Pay and Print</a>
</span>
</span>
</div>
</div>
Buttons on other pages can be clicked with no issues.
I am assuming it has something to do with the href="javascript:void(0);" portion of the HTML but do not know why. In a browser such as IE or Firefox when this button is clicked something like a progress bar appears and say "Processing" for a few seconds and then the next page loads.
EDIT:I should mention that the Navigating handler fires twice and then the page freezes.

This is apparently caused by IE7+'s "Script URL Mitigation" feature and can be fixed for your application by disabling FEATURE_SCRIPTURL_MITIGATION.

Related

Using Modal Popup for Displaying aspx page inside another aspx page

I have the below code which I am using to open a aspx page inside a modal popup but the issue is as soon as I load the host page of the modal popup it is redirecting to the one which is inside the iFrame.
<cc1:ModalPopupExtender ID="mp1" runat="server" PopupControlID="Panl1" TargetControlID="Button1"
CancelControlID="Button2" BackgroundCssClass="Background">
</cc1:ModalPopupExtender>
<asp:Panel ID="Panl1" runat="server" CssClass="Popup" align="center" Style="display: none">
<iframe style="width: 350px; height: 300px;" id="irm1" src="PayrollScope.aspx?id=49437" runat="server"></iframe>
<br />
<asp:Button ID="Button2" runat="server" Text="Close" />
</asp:Panel>
So the sequence is
MainPage.aspx -> Click PopUp -> Load PayrollScope.aspx inside the modal
But as soon as I hit the MainPage.aspx it is redirecting to PayrollScope.aspx. I tried to use jQuery modal popup also but the same issue is happening. Can someone please tell me why it's redirecting.
Thanks
If you use jQuery dialog to load that other page?
Well, it will display, but THEN if any code in the page has a post back, then yes, it will re-direct to that page.(jQuery dialog simply pulls the whole other page right into that div and "merges" it into your current page's dom. So, you can display the page, and no re-direct will occur. However, any server side button event code (button press, or even say a after update event of editing a text box (on changed) will cause a post back. And any post-back WILL thus cause the page to re-direct (after all any code behind event does send the WHOLE page back and the URL to IIS. So, it much depends on if you JUST displaying that page, or if you want/need/have user interaction on the 2nd page loaded as a dialog.
So, dump the ajax popup and controls reverence to the id of the popup. (don't try jQuery an the ajaxtool kit to "both" try and pop up a control/div - they tend to not play nice with each other.
I do suggest using jQuery.
This would work (but with above post back issues in mind).
<body>
<form id="form1" runat="server">
<br />
<asp:Button ID="Button1" runat="server" Text="Show page as dialog" OnClientClick="showpage1();return false"/>
<div id="poppage" runat="server" style="display:none">
</div>
<link href="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.min.css" rel="stylesheet" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
<script>
function showpage1() {
var mydiv = $('#poppage');
mydiv.dialog({
autoOpen: false, modal: true, title: 'My cool other page', width: '50%',
position: { my: 'top', at: 'top+150' }
});
mydiv.load('MyOtherPage.aspx');
// Open the dialog
mydiv.dialog('open');
}
So, above will LOAD the other page (into that div), thus pop up the 2nd page when you click on the above button. (and note the return=false). If you have any postback on the page, then everything will quite much blow out the dialog. (and this also means the 2nd page we display (load) as per above.
However, if you need interaction on that 2nd page? (have to click on buttons etc.).
Then the idea of a iframe is a VERY good idea.
So, you have same as before, but we now don't "load" the page using jQuery.ui, but JUST display (and thus pop up) the div with a iframe you placed inside.
So,the div becomes this:
<div id="poppage" runat="server" style="display:none">
<iframe src="MyOtherPage.aspx" class="auto-style1"></iframe>
</div>
and the js code becomes this:
function showpage1() {
var mydiv = $('#poppage');
mydiv.dialog({
autoOpen: false, modal: true, title: 'My cool other page', width: '50%',
position: { my: 'top', at: 'top+150' }
});
// Open the dialog
mydiv.dialog('open');
}
So, now the above will just display that other page in the div, and since it is a iFrame, then you can interact - and post backs in that iframe should work just fine.
So, remove the ajax panel stuff - give jQuery.ui a try. I used the ajaxtool kit stuff, but for displaying another whole page in a dialog, then i found jQuery.ui seems to work a lot better

Cannot close Ajax ModalPopupExtender Modal window which is created from a master page

I have a Website project with a master page with the standard default Microsoft theme that is created when starting a new project.
I created a Search page that I want to call from this menu and put the new anchor tag within this standard menu. The click of the search link will pull up a modal and bring in my search.aspx page within it.
<li>Search</li>
function Search() {
document.getElementById('<%= hdnButtonSearch.ClientID%>').click();
}
This is the modal the source is a webform Search.aspx
<asp:ModalPopupExtender ID="ModalSearch" runat="server" PopupControlID="Panl1" TargetControlID="hdnButtonSearch"
CancelControlID="Button2" BackgroundCssClass="modalBackground" ></asp:ModalPopupExtender>
<asp:Panel ID="Panl1" runat="server" CssClass="Popup" align="center" style = "display:none">
<iframe style=" width: 800px; height: 600px;" id="irm1" src="Search.aspx" runat="server"></iframe>
<br/>
<asp:Button ID="Button2" runat="server" Text="Close" />
</asp:Panel>
I could call this modal window from being on any of the webforms just by clicking the Seach link within the menu.
Now the Problem.
I Call and open up the modal extender and it opens the search.aspx webform.
On this webform I want to put a button to close the modal.
I don't want to use the standard button in this case Button2 within the ModalPopupExtender I want to use a button that is actually on the Search.aspx page.**
What will really happen is the user searches for a client the client goes inside a grid and then the client wants to view that client so they click a link button within the gird which loads the client and then I want the modal to close.
How could I close this modal within the search.aspx page?
The search page does not have a MasterPageFile its just a webform that pops up within the modal.
In the search page I have a button. That calls the Javascript function to close the modal but it does not work I get an error.
Microsoft JScript runtime error: Object expected
function HideModalPopup() {
$find("ModalSearch").hide();
return false;
} </script>
Your search.aspx page is being rendered into the modal but is effectively part of the same page. This isn't an iframe, so you can assume it has full access to the DOM and all the available scripts.
Whatever JavaScript function you already have in place to close the modal, call that from the relevant client-side control from your search.aspx page.

Saving dynamically generated html attributes in a database (Asp.Net, Jquery)

I am working on a self design dashboard page. Users drag&drop custom sized boxes in a div element and place some data inside boxes. Once they finish, I would like to save the certain attributes of these boxes in a db, instead of saving whole html code.
<div id="widget0" class="box span2">
<div class="box-header well" style="padding-left: 3px;" data-original-title="">
<div style="float:left">
<i class=" icon-chevron-left"></i>
<i class=" icon-chevron-down"></i>
<i class=" icon-chevron-up"></i>
<i class=" icon-chevron-right"></i>
</div>
<div style="float: right !important; margin-right: -15px;">
<i class="icon-remove"></i>
</div>
</div>
<div class="box-content">
<div id="boxContent0" style="width:100%;height:250px;border-collapse:collapse;" class="ui-droppable">
</div>
</div>
</div>
Above is a sample html code of my box. I'll just save div id, class and contents.
What I've done so far is, I saved required values in an asphiddenfield on a button click event in this format:
"2|widget0,span4,content1,content2|widget1,span3,0,0"
I did this by handling form submit event using jquery, triggered by asp button click. But the db write operations required in my server button click function didn't work. I think this is because I handled the form submit event before btnSaveDashboard_Click(object sender, EventArgs e) function handles and submit the form from jquery..
What I would like to do is, when user click on "save dashboard" button, before redirecting to the dashboard view page, to save these values in my db then redirect.
I just couldn't find a way how to do this with one button click;
get the required html values
save them in a hidden field or somewhere else reachable like viewstate
save these values in my database
I can more provide more details in case needed.
Thanks.
You could use the Button's OnClientClick client side event to populate the HiddenField with the values you need before the Postback occurs.
If you accomplish that, you should have the values you want on the Button's OnClick server side event. You should be able to do whatever you want with them at this point.

How to disable the page and display a In process text Or a Loading in Asp.net website

I call a method to Send Email to the user ID and Redirect to the same page. Since the time taken for the server to send email is high, the page appears as if the send button is not clicked. Since there are no response from the website. I want to display a loading image or something, to show that the server is processing the request. How can I do that
You can use an UpdateProgress control
http://msdn.microsoft.com/en-us/library/bb398821.aspx
(Or even better: send the e-mail asynchronous in the background)
You can use either with an UpdateProgress control (as covered in the other answers), or a simple piece of jQuery.
jQuery example:
$('#my-button-id'').click(function(){
$('#my-button-id').hide();
$('#my-loading-image-id').show();
});
Remember to reenable the button if the action does not complete properly, else the user will not be able to try again.
Im not to familair with the UpdateProgress myself, but have seen it used before.
You need to have an animated gif, and the update progress will show this whenever the page is busy.
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
<div class="">
Processing Please Wait...
<img runat="server" id="ajaxLoader" src="~/images/loadinfo.net.gif" alt="loading" /></div>
<div class="" style="height: 10px;">
</div>
</ProgressTemplate>
</asp:UpdateProgress>
With regards to actually disabling the page, this I dont think can be done.

Fancybox event is not fired

i have my login in a fancybox and fancybox div is in a controller. problem is if click the button nothing happens event isnt fired.
this is my controller.ascx
<div id="inline1" style="width:400px;">
<ul class="forms">
<li class="inputfield"><asp:TextBox ID="kullanıcı_adi" runat="server"></asp:TextBox></li>
</ul>
<ul>
<li><asp:TextBox ID="sifre" runat="server"></asp:TextBox></li>
</ul>
<ul>
<li>
<asp:Button ID="Button1" runat="server" Text="Giriş Yap"
onclick="Login_Authenticate" />
<asp:Button ID="Button2" runat="server" Text="Vazgeç"/>
</li>
</ul>
</div>
and this is my cotroller.ascx.cs
protected void Login_Authenticate(object sender, EventArgs e)
{
bool authenticated = AuthenticateMe(kullanıcı_adi.Text, sifre.Text, true);
if (authenticated)
{
FormsAuthentication.RedirectFromLoginPage(kullanıcı_adi.Text, true);
}
}
and this is the default.aspx
<li class="gallery"><a id="various1" href="#inline1">Üye ol/Giriş Yap</a></li>
<div style="display: none;">
<co:c_login ID="id_c_login" runat="server" EnableViewState=true />
</div>
I found the solution. Same question asked before.
Fancybox - ASP.NET button not working Thank you for your answers.
A bit late, but it may help you.
This is because how fancybox works, when fancybox displays the div block, it creates temporary div block with your content and appends it to end of the body tag of the page, hence this generated temporary block is created outside form tag.
In a web page when you postback a page, the control which generates postback event must be within form tag to identify the page postback action.
To resolve this issue you can use a bit of javascript, create another button control but it should not be part of fancybox control, and on submit button within fancybox, fire click event of another created button (which will be inside form tag) with help of javascript.
That should solve your problem, please vote if it answer your question.
We can solve fancybox 2 event not firing issue by using parent property of fancybox.
for example -
$("#buttonClick").fancybox({
parent: "form:first",//Asp.net Button click event not working issue solved by using this statement
......your fancybox config options
});

Categories

Resources