|
That's not possible as browsers control file downloads for security reasons. For your page to react to the download it would need a hook into the download process which it simply doesn't have.
|
|
|
|
|
If you can drop support for old browsers - including any version of Internet Explorer - then something like this might work:
Javascript - Downloading Files with AJAX and Showing a Progess Bar[^]
NB: If the user navigates away from your page whilst the file is downloading, the download will be aborted. It's generally much safer to use the standard file download options, which will let the browser continue downloading the file in the background whilst the user continues working.
You'll also want to make sure that you add the SessionStateAttribute[^] to your Export controller to disable session state, or set it to read-only. Without that attribute, only one request for a single session can be processed at a time.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I did try by applying [SessionState(SessionStateBehavior.ReadOnly)] to the Export Controller but when I click on download and navigate to another pages(download process is being prepared like getting data from database and loads into excel and then downloads) download stops.
How to achieve this?: the standard file download options, which will let the browser continue downloading the file in the background whilst the user continues working.
|
|
|
|
|
you can use hangfire to do that
=====================================================
The grass is always greener on the other side of the fence
|
|
|
|
|
In my ASP.Net (C#) webforms application, I've noticed that some (all?) of the generated form fields have an extra attribute, "wtx-context" with a GUID value; e.g.
<input type="submit" name="ctl00$grdConfig$ctl04$btnAdd" value="Add New" id="btnAdd" wtx-context="FC3AB902-A74E-4209-8E0D-9F9AC5F15021"> I don't recall ever seeing this in any other of my sites, yet it's happening when running the site via VS2015's development server, and when running on a remote shared host. Searching Google for "wtx-context" returns virtually nothing, and nothing relevant.
Has anyone else come across this, what does it do, and is it an issue?
Confused!
|
|
|
|
|
Hi,
I'm seeing this too - did you ever figure it out?
Ben
|
|
|
|
|
No, never got to the bottom of it. I still see it occasionally, but not as much... Still no useful info when googling, though at least one other dev has seen it some time ago.
|
|
|
|
|
I am trying to insert HTML elements dynamically into an empty DIV element on my VB.net web form when buttons are clicked. Each button will insert a different set of elements. In my jQuery function I made sure the DIV that will receive the new contents is cleared before adding new contents to it.
This works if I take the script and markups and put them in a regular html file but when I try this in my VB.net web form, the new elements show up for a split second then they are cleared.
I think it has to do with PostBack so I put the code below in Pageload.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Page.IsPostBack Then
ClientScript.RegisterHiddenField("isPostBack", "1")
End If
End Sub
Then in my jQuery document ready function I check for PostBack with the following code
var isPostBackObject = document.getElementById('isPostBack');
if (isPostBackObject != null) {
}
What am I doing wrong, why isn't it working?
modified 2-Dec-18 11:21am.
|
|
|
|
|
Chances are your code is instigating a postback which is causing the page to refresh. In the javascript you run when the button is clicked make sure the function returns false, or if you're using jquery then use e.preventDefault().
You can probably google "javasctipt prevent postback" for specific code examples.
|
|
|
|
|
Hey can someone kindly help me create models views and controllers using C sharp to write the code
|
|
|
|
|
Did you want to describe the problem your having with more detail?
As it stands now, there's really nothing for anyone to say other than to tell you to either find MVC tutorials on the web or pick up a book on MVC.
|
|
|
|
|
I need help adding html helpers,partial pages,JavaScript ,DbInitializer
|
|
|
|
|
As Dave already suggested, you need to Google for articles or get hold of a good book. No one here is going to do the work for you.
|
|
|
|
|
|
I currently have a solution which contains two projects: an ASP.NET site and a Web API project. On the site, I have a page that is meant to call the API using the POST method at address http://localhost:52855/api/v1/GetPrices asynchronously (e.g. response = await base.SendAsync(request, cancellationToken where "base" is a DelegatingHandler). Part of the data that is posted is an API key along with a signature to ensure the user is authorized. However, nothing happens; the Chrome tab just shows the loading symbol continuously.
But, if I use Fiddler and make a POST request to the same address (http://localhost:52855/api/v1/GetPrices), but without the API/signature information, I get back the correct response - a 401 Unauthorized and a "WWW-Authenticate: amx" header (where "amx" is the authentication scheme I'm using for testing. If I include the authorization header in Fiddler then I get a 500 Internal Server Error
My biggest question is how can I debug the Web API project in Visual Studio 2017 Enterprise edition? I have breakpoints set on all the methods (e.g. the Post method in my GetPricesController : ApiController as well as my HMACAuthenticationAttribute which implements the IAuthenticationFilter). I feel that if I can at least start seeing what's going on when I make the requests with Fiddler, that I may be able to figure out the web app from there.
I'm supposed to be doing a demo on this Web API project tomorrow early afternoon and I've been working for the back 11 hours on finishing this up but I'm completely stalled now and have no idea where to go from here. Any help/guidance would be so greatly appreciated. Thank you.
P.S. I was using this article http://bitoftech.net/2014/12/15/secure-asp-net-web-api-using-api-key-authentication-hmac-authentication/ to implement the API key validation.
A black hole is where God tried to divide by zero.
There are 10 kinds of people in the world; those who understand binary and those who don't.
|
|
|
|
|
Hi,
To debug your API you can write another console application which calls your API. Set the api url to your localhost address, then run your WEB API project(by setting the start project on it), now when you run your console application and call your API, your break point will work 
|
|
|
|
|
guys Can you help me with this issue i do not know how to write EditItemTempalte in gridView wih sqlCommand !!!!!can you give me sample code 
modified 26-Nov-18 3:31am.
|
|
|
|
|
Are list contents volatile ? e.g I've declared a list
Dim AdminFinalFilename As New List(Of String)
On a button press I pass a string into the list
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
finalfilename = DateTime.Now.ToString("ddMMyyhhmm") + "_" + FileUpload1.FileName
AdminFormFilename.Add(finalfilename)
End Sub
On pressing another button the contents of the list disappear
Protected Sub FormSubmit_Click(sender As Object, e As EventArgs) Handles FormSubmit.Click
If AdminFinalFilename Is Nothing Then
Else
Dim i As Integer
For i = 0 To AdminFinalFilename.Count - 1
Dim y As New accessadminreq
y.InsertAdminUpload(FormID, (AdminFinalFilename.Item(i)))
Next i
End If
End Sub
|
|
|
|
|
You are adding items to AdminFormFilename , but listing from AdminFinalFilename ?
|
|
|
|
|
My bad, I posted the wrong paste sorry
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
finalfilename = DateTime.Now.ToString("ddMMyyhhmm") + "_" + FileUpload1.FileName
AdminFinalFilename.Add(finalfilename)
End Sub
|
|
|
|
|
Values stored in fields are not persisted between requests. This is a common misunderstanding of how ASP.NET works.
The browser makes a request. ASP.NET creates a new instance of your page class, and loads any data that was included in the request via the query-string or a form POST. The page then processes the request, and generates a response. The response is sent to the browser, and the instance of your page class is thrown away.
When the browser makes its next request, it's processed by a new instance of your page class, which doesn't carry over any of the field values from the previous instance.
To make data persist between requests, it either needs to be stored in the session, or included in the query-string or form POST data for the next request. The standard approach for data that only relates to a single page is to use view state.
Understanding ASP.NET View State[^]
NB: Judging by the variable names, you've also hit another common misunderstanding about how file uploads work. The FileName property is the path - or sometimes just the name - of the file on the user's computer. It is included for information only. Your code is running on the server, and has no access to that path.
Instead, you need to save the file somewhere on the server, or read the file data from the input stream and process it.
How to: Upload Files with the FileUpload Web Server Control[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks, the file upload works this was some example code - I usually get the path with
Dim path As String = Server.MapPath("~/Uploads/")
and upload with
FileUpload1.PostedFile.SaveAs(path & _
finalfilename)
Saves the files fine, I'm just trying to loop through if there is more than one uploaded file and insert them into a database for retrieval later.
What's odd is I just threw together a test with this and it works like I thought it should
Dim mylist As New List(Of String)
Protected Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
mylist.Add("button3 clicked")
Dim i As Integer
For i = 0 To mylist.Count - 1
Label4.Text = Label4.Text + (mylist.Item(i)) + "<br>"
Next i
End Sub
Protected Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
mylist.Add("button4 clicked")
Dim i As Integer
For i = 0 To mylist.Count - 1
Label4.Text = Label4.Text + (mylist.Item(i)) + "<br>"
Next i
End Sub
|
|
|
|
|
caffrey_1 wrote: it works like I thought it should
I doubt that.
The label's text will be persisted between requests, because it uses view state. When you append the items from the list, you're only appending a single item each time; the previous items were already in there.
If you debug your code and look at the myList field, you'll see it's empty when you click the button.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Your right, I'm having a day
Thanks for the pointer - I think I can get it fixed now
Problem I have I mix between coding in vb and aspx most days!
Thanks
|
|
|
|
|
Hi,
I have two reports in my Application, Report A is without Groups in it, and Report B with Groups in it, both are set with Columns Property: Column Headers -> Repeat Header Columns on each Page,
but the Report without Groups is showing column headers on each Page, when Report B with groups is not showing the Column headers on each page. Any help please, I am using ReportViewerForMVC tool for the Report viewing, maybe if it has any impact on it.
Just in case I selected the Row Headers - Report header column on each page too still didn't help.
But any help would be greatly helpful - thanks in advance friends
|
|
|
|