Back in the ASP classic days when i needed to write out the name/value pairs of forms submitted by POST i thru this loop into the page: on error resume next for each x in Request.Form Response.AppendToLog x & "=" & Request(x) next. It threw all the form fields and values into the log just as GETs are. Does IIS7 .net give me any better method? (this is for the dev/testing portion of the project i don't have any concern about the space or cycles used to accomplish this).
I'm just wondering what people use to stop user from click a submission button more than once thus creating many records. Does any one have any examples that take client-side validation into account. I have done much research on this but am yet to find a feasible solution.
using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; public partial class ResponseTest : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { var a = Request; //I didn't find the data in Request's structure. Response.Write("successed; hello World;"); } } //-----------------------javascript-------------- for( var i=0; i<this.dataToBeSent.length && this.dataToBeSent[i].hasSent == false; i++ ) { xmlRequest.open("POST",this.dataToBeSent[i].url,true); xmlRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlRequest.setRequestHeader("Content-length", this.dataToBeSent[i].data.length); xmlRequest.setRequestHeader("Connection", "close"); xmlRequest.onreadystatechange = function() { var j = j || i; if(xmlRequest.readyState == 4 && xmlRequest.status == 200) { if( xmlRequest.responseText.toLowerCase().indexOf("successed") > -1 ) { this.dataToBeSent[i].hasSent = true; } } }; xmlRequest.send(this.dataToBeSent[i].data); // xml data }
I have a linkbutton inside a repeater's item templete and i want to access the link buttons text on the next page.I set the postbackurl to the next page.But when i use the page.PrevoiusPage.Findcontrol("lnkReport") on the destination page's code behind, I get a null value .These are the markups.
If I were using PHP I could submit a form to a new page, or the same page, and get the posted variables by doing something such as $_POST['txtVariable'], how do I do the same thing in ASP.NET? And is it possible to have more than one form per page?
I am writing an application in which a remote url web site ( says url1 that is sender) sends xml data to another web site (says url2 that is receiver) by using .NET WebRequest. On the receiver url2 if I use .NET Page.Response and .NET Page.Request to store posted/received xml data into an external text file, then the data is stored. However, if I store the received data into database, I do not see the data is stored into the database.
trouble shoot the codes so I can store such remotely posted data into database on the receiver side url2.
I host both url1 site and url2 site in my computer using IIS like [URL]
1/ Receiver page's codes that store remotely posted xml data into database do not work:
protected void Page_Load(object sender, EventArgs e) { Page.Response.ContentType = "text/xml"; StreamReader reader = new StreamReader(Page.Request.InputStream); String xmlData= reader.ReadToEnd(); ProductNameSapce.ProductCollection.InsertReceivedProduct(xmlData).ToString(); // data is not stored ; the method is tested and works well with hard-coded data reader.Close(); Page.Response.End(); }
2/ The version of the receiver page at url2 that stores into an external text file works:
protected void Page_Load(object sender, EventArgs e) { Page.Response.ContentType = "text/xml"; StreamReader reader = new StreamReader ( Page.Request.InputStream ); String xmlData= reader.ReadToEnd (); StreamWriter s; s= File.CreateText ( Server.MapPath(".")+@""+ Guid.NewGuid () + ".txt" ); s.WriteLine ( xmlData); // data is stored in an external text file s.Close (); reader.Close(); Page.Response.End(); }
I am using a third party applet which enables a user to paste a screen shot into it and it posts the file data to an upload page. I am pretty new to asp.net (VB) and wondered if I could use a Generic Handler to read the post data and save the file to disk or just a normal web form to do this? All the examples I have received with the applet are in php of which i have had no experience coming from a Classic ASP background.
Whatever server Control we take on aspx page while in coding phase, all those controls are converted to html controls through the asp.net engine and sent to the requesting web browser. That's fine.
Now, all the controls that are rendered on the browser are html controls. I am bit confused that how after pressing any button (Or any such control that post back pages) page is posted back to the asp.net engine. How such html controls comes to know where (address) they have to go?
I have a datalist and gridview that have a image in a column.. when you click the imagebutton, its calls my method that updates a table. The page is posting during this event, but when the page is done, the image hasnt changed.. im sure it has to do with the datasource not binding during that click.. so where can i move this code to or can i simply bind the control during that click? Currently im handling it in the itemdatabound event.. which would explain it.. but where is the correct place to handle this logic?
I've a grid view which could have huge data. When any control like a button causes the postback, I do not want gridview data to post back as it is not required and results in slower responses.
I am working on a comparison tool that will take an excel file and a .csv file and find differences. The user is going to be selecting the two files from their local machine via the .NET FileUpload control. The issue I am running into is that I don't want to write the files to the server first so using something like below won't work for me, as "Book1.xls" or even " + FilePath + " in place of it won't work. I need to be able to read the posted files into memory, then create maybe datatables of them, then do my comparison code.
[Code]....
I have some code that reads the PostedFile into a stream but I don't know how I can use that stream with the above code. Then I have some that can read the .csv file, but if it is an excel file, I get a bunch of Excel garbage along with the data...
[Code]....
How can I read into clean data from a FileUpload control of an Excel document?
I am building an application that allows a user to upload multiple images, resizes them, and saves them. What I need (ok, what I'd like) is the following...
I would like some sort of way to prompt a user to crop the photos after they have been saved. I have code that creates a 175px square rectangle and saves that image. I need the user to select the image section they want saved and to do so I envision a window that automatically prompts them to do so once the upload(s) have completed. I think my preference would be to have a page or control (datalist, repeater, ectc..) that refreshes every time an image is saved and allows the user to crop the newly saved images. I'm opened to advice, opinions, free drinks and a clue.
I am creating an ASP.NET application that allows the user to add form elements to a page within a form. When the page is posted (via the submit button) I need to loop through ALL the posted values in the form and get the values.
I can't check for specific values as I don't know how many there will be or what they will be called.
Could someone point me in the right direction of getting ALL posted values so I can loop through them?
p.s I was looking in Request.Form but couldn't see anything obvious to use.
My result is that the value of the input button is always "change" when the browser loads the page, but I was expecting it to be "new-value" after postback. The Javascript doTest() function is changing the value when the button is clicked.Is there something more I'm supposed to do for ASP.NET or IE to get the input button value posted back? Or is the information about this functionality wrong?
Lets say you have a page with headers that tell the browser not to cache.Also, this page has already been posted back to itself.Now you hit the refresh button and you click cancel on the IE modal box with the "previously submitted..." message.You get "Webpage has expired". This doesn't happen in FF or Chrome.Is there a way to prevent the "Webpage has expired" message in IE?Since the page isn't cached, I guess IE has nothing to render.But if the page isn't cached and FF and Chrome shows it, I guess they just show the page as previously shown?
I'm developing a httpHandler, in my source code if some conditions aren't met i would like to stop uploading file to the server ( for example file extension is not allowed)
When I try to quit ProcessRequest function with return null;, asp.net tries and uploads the file automatically before I quit the httpHandler...
How can I stop asp.net to automatically upload posted files?
Here is the list of thing I've tested so far and no luck:
public void ProcessRequest(HttpContext context) { var worker = (HttpWorkerRequest)provider.GetService(typeof(HttpWorkerRequest)); .......... worker.CloseConnection(); context.Response.End(); Environment.Exit(0); return null; }
i always got the empty string in form data posting. can you describe what the hell happened in my code? always got the empty string to insert to SQL server even it is drop down list selected value is empty. Is this the error in visual studio cause sometimes i can get the value and sometimes can't (inconsistent!!!)
Protected Function sqlparameter_insert_newscat() As SqlParameter() Dim sqlparam(4) As SqlParameter Dim ddlstatus As Boolean If rbActive.Items(0).Selected = True Then [code]...
This is the first time I've come across this kind of problem before and I'm having trouble approaching it.
I have a swf developed by someone else that posts an image and I have to create a handler of some kind to capture it, name it, then upload it to a directory. I've tried a couple ways and nothing is working.
this is a quick an dirty approach, just an aspx file
<%@ Page Language="C#" %> <%@ Import Namespace="Components" %> <%@ Import Namespace="System.IO" %> <script runat="server"> public partial class upload : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string uploadDirectory; uploadDirectory = Server.MapPath(@"images/"); string imageName = "image.jpg"; string uploadPath = uploadDirectory + imageName; //FileUpload imageUpload = new FileUpload(); // Get the data from the POST array string Email = Request["email"]; HttpPostedFile imageFile = _context.Request.Files["image"]; imageFile.SaveAs(uploadPath); } } </script>
this is another approach using a handler.
<%@ WebHandler Language="C#" %> using System.IO; using System.Web; using System.Web.Configuration; using System.Web.IHttpHandler; public class Uploader : IHttpHandler.i { public void ProcessRequest( HttpContext _context ) { string uploadDirectory; uploadDirectory = Path.Combine(_context.Request.PhysicalApplicationPath, @"images"); //uploadDirectory = Server.MapPath(@"images/"); string imageName = "image.jpg"; string uploadPath = uploadDirectory + imageName; //FileUpload imageUpload = new FileUpload(); // Get the data from the POST array string Email = _context.Request["email"]; HttpPostedFile imageFile = _context.Request.Files["image"]; imageFile.SaveAs(uploadPath); } }
i want show time data posted. for example 18 second ago or 4 min and 36 second ago or 2 day ago. for example my post in forum asp.net. this is Procedure: but not run.
@DATEDIFF INT=0 as If (SELECT DATEDIFF(Minute, date, GETDATE()) AS Minutes) FROM tblajax > 60 BEGIN SELECT Id, name, family, age, (SELECT DATEDIFF(Minute, date, GETDATE()) AS Minutes) FROM tblajax END ELSE BEGIN SELECT Id, name, family, age, (SELECT DATEDIFF(Second, date, GETDATE()) AS Second) FROM tblajax END
I've got stuck for this for a long time. I always got empty value for the posted data. Here is my code:
Protected Function sqlparameter_insert_newscat() As SqlParameter() Dim sqlparam(4) As SqlParameter Dim ddlstatus As Boolean If rbActive.Items(0).Selected = True Then ddlstatus = True Else ddlstatus = False End If sqlparam(0) = New SqlParameter("@username", SqlDbType.VarChar, 30, ParameterDirection.Input, False, 0, 0, "", DataRowVersion.Current, Session("user.id")) sqlparam(1) = New SqlParameter("@news_category", SqlDbType.VarChar, 255, ParameterDirection.Input, False, 0, 0, "", DataRowVersion.Current, news_category.Text) 'Response.Write(HttpContext.Current.Request.Form(name)) sqlparam(2) = New SqlParameter("@news_category_desc", SqlDbType.Text, 1000000, ParameterDirection.Input, False, 0, 0, "", DataRowVersion.Current, HttpUtility.HtmlEncode(news_category_desc.InnerText)) sqlparam(3) = New SqlParameter("@news_category_status", SqlDbType.Bit, 1, ParameterDirection.Input, False, 0, 0, "", DataRowVersion.Current, ddlstatus) sqlparam(4) = New SqlParameter("@news_category_parent", SqlDbType.BigInt, 100, ParameterDirection.Input, False, 0, 0, "", DataRowVersion.Current, ddlRoot.SelectedValue) Return sqlparam End Function
the news_category.text always the empty string even the dropdownlist selected value return empty string. Is this an error of bug in Visual Studio 2010? I 've got stuck for this for long time and i have been nearer to deadline. I just made change "ValidateRequest = False" to aspx file to permit html tag to be posted.
I am building a DropDownList control dynamically. Constraining this discussion to within just the OnInit() method / state in the asp.net lifecycle, is the only way to see the dropdownlist's posted value to look at the Request.Form NameValueCollection? I m aware that the dropdownlist's viewstate is restored by the time OnLoad() is reached, but I need it's value before then (im pretty sure LoadViewState($object) is of no use?)
I know this has got to be the simplest-sounding question ever asked about ASP.Net but I'm baffled. I have a form wherein my visitor will enter name, address, etc. Then I am POSTing that form via the PostBackUrl property of my Submit button to another page, where the fields are supposed to be all re-formed into new hidden fields, then POSTed again to Paypal.
My problem is I cannot get at the values entered by the visitor in the original page. Any time I put in "runat='server'", ASP.Net completely changes the ID of the control, making it impossible to figure out how to access. In the POSTed form I tried Request.Form["_txtFirstName"] and that turned up null. Then I tried ((TextBox)PreviousPage.FindControl("_txtFirstName")).Text and that was null, too. I've tried variations on those. I cannot figure out how I'm supposed to get at these controls. Why does this stuff need to be so difficult?