|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Posting using httpwebrequestHi,
Should the form submit button click event handler fire when posting to a aspx page using httpwebrequest. In my tests the load event fires when POSTing back but not the button click event handler. I first issue a GET, extract __VIEWSTATE and then POST back __VIEWSTATE and the form values. I am hoping to use this technique for a screen scraper but if I can't get the submit buttons click event handler to fire its no use. Thanks, Pazza Are you posting any value for the button when posting the form values? My
guess is you would have to post something like "Button1=Button". Otherwise the asp.net framework has no way of telling that the button has been "clicked". HTH, Jakob. Show quoteHide quote "Pazza" wrote: > Hi, > > Should the form submit button click event handler fire when posting to a > aspx page using httpwebrequest. > > In my tests the load event fires when POSTing back but not the button click > event handler. > I first issue a GET, extract __VIEWSTATE and then POST back __VIEWSTATE and > the form values. > > I am hoping to use this technique for a screen scraper but if I can't get > the submit > buttons click event handler to fire its no use. > > Thanks, > Pazza > > Yep, I'm posting Button1=Clicked, see below ...
viewState = SrcViewState 'a readonly property that gets __VIEWSTATE postData.Append("__VIEWSTATE=") postData.Append(viewState) postData.Append("&Button1=Clicked") Dim encodedPostData As String encodedPostData = HttpUtility.UrlEncode(postData.ToString) hrqURL = HttpWebRequest.Create(m_strURL) hrqURL.ContentType = "application/x-www-form-urlencoded" hrqURL.ContentLength = encodedPostData.Length hrqURL.Method = "POST" Dim cookies As New CookieContainer hrqURL.CookieContainer = cookies Dim requestWriter As New StreamWriter(hrqURL.GetRequestStream()) requestWriter.Write(EncodedPostData) requestWriter.Close() hrspURL = hrqURL.GetResponse() Show quoteHide quote "Jakob Christensen" wrote: > Are you posting any value for the button when posting the form values? My > guess is you would have to post something like "Button1=Button". Otherwise > the asp.net framework has no way of telling that the button has been > "clicked". > > HTH, Jakob. > > > "Pazza" wrote: > > > Hi, > > > > Should the form submit button click event handler fire when posting to a > > aspx page using httpwebrequest. > > > > In my tests the load event fires when POSTing back but not the button click > > event handler. > > I first issue a GET, extract __VIEWSTATE and then POST back __VIEWSTATE and > > the form values. > > > > I am hoping to use this technique for a screen scraper but if I can't get > > the submit > > buttons click event handler to fire its no use. > > > > Thanks, > > Pazza > > > > I can not get it working when posting __VIEWSTATE (It results in an internal
server error). My suggestion is that you don't try to fire the Click event of the button. Instead change your code to something like (assuming you control the server code): if (Request["Button1"] != null) { // do some work } Or perhaps a web service is the way to go? Regards, Jakob. Show quoteHide quote "Pazza" wrote: > Yep, I'm posting Button1=Clicked, see below ... > > viewState = SrcViewState 'a readonly property that gets __VIEWSTATE > postData.Append("__VIEWSTATE=") > postData.Append(viewState) > postData.Append("&Button1=Clicked") > Dim encodedPostData As String > encodedPostData = HttpUtility.UrlEncode(postData.ToString) > hrqURL = HttpWebRequest.Create(m_strURL) > hrqURL.ContentType = "application/x-www-form-urlencoded" > hrqURL.ContentLength = encodedPostData.Length > hrqURL.Method = "POST" > Dim cookies As New CookieContainer > hrqURL.CookieContainer = cookies > Dim requestWriter As New StreamWriter(hrqURL.GetRequestStream()) > requestWriter.Write(EncodedPostData) > requestWriter.Close() > hrspURL = hrqURL.GetResponse() > > "Jakob Christensen" wrote: > > > Are you posting any value for the button when posting the form values? My > > guess is you would have to post something like "Button1=Button". Otherwise > > the asp.net framework has no way of telling that the button has been > > "clicked". > > > > HTH, Jakob. > > > > > > "Pazza" wrote: > > > > > Hi, > > > > > > Should the form submit button click event handler fire when posting to a > > > aspx page using httpwebrequest. > > > > > > In my tests the load event fires when POSTing back but not the button click > > > event handler. > > > I first issue a GET, extract __VIEWSTATE and then POST back __VIEWSTATE and > > > the form values. > > > > > > I am hoping to use this technique for a screen scraper but if I can't get > > > the submit > > > buttons click event handler to fire its no use. > > > > > > Thanks, > > > Pazza > > > > > > Thanks again Jakob,
Scraping is my only option as I have no control over the source application and it doesn't provide any webservice(s). I would still like to known if the buttons click event should fire, is there anyone out there you can help please ? Show quoteHide quote "Jakob Christensen" wrote: > I can not get it working when posting __VIEWSTATE (It results in an internal > server error). My suggestion is that you don't try to fire the Click event > of the button. Instead change your code to something like (assuming you > control the server code): > > if (Request["Button1"] != null) > { > // do some work > } > > Or perhaps a web service is the way to go? > > Regards, Jakob. > > > "Pazza" wrote: > > > Yep, I'm posting Button1=Clicked, see below ... > > > > viewState = SrcViewState 'a readonly property that gets __VIEWSTATE > > postData.Append("__VIEWSTATE=") > > postData.Append(viewState) > > postData.Append("&Button1=Clicked") > > Dim encodedPostData As String > > encodedPostData = HttpUtility.UrlEncode(postData.ToString) > > hrqURL = HttpWebRequest.Create(m_strURL) > > hrqURL.ContentType = "application/x-www-form-urlencoded" > > hrqURL.ContentLength = encodedPostData.Length > > hrqURL.Method = "POST" > > Dim cookies As New CookieContainer > > hrqURL.CookieContainer = cookies > > Dim requestWriter As New StreamWriter(hrqURL.GetRequestStream()) > > requestWriter.Write(EncodedPostData) > > requestWriter.Close() > > hrspURL = hrqURL.GetResponse() > > > > "Jakob Christensen" wrote: > > > > > Are you posting any value for the button when posting the form values? My > > > guess is you would have to post something like "Button1=Button". Otherwise > > > the asp.net framework has no way of telling that the button has been > > > "clicked". > > > > > > HTH, Jakob. > > > > > > > > > "Pazza" wrote: > > > > > > > Hi, > > > > > > > > Should the form submit button click event handler fire when posting to a > > > > aspx page using httpwebrequest. > > > > > > > > In my tests the load event fires when POSTing back but not the button click > > > > event handler. > > > > I first issue a GET, extract __VIEWSTATE and then POST back __VIEWSTATE and > > > > the form values. > > > > > > > > I am hoping to use this technique for a screen scraper but if I can't get > > > > the submit > > > > buttons click event handler to fire its no use. > > > > > > > > Thanks, > > > > Pazza > > > > > > > >
Microsoft: Help with OLE documents...
How to Deserialize to a specific object instance. .NET Framework 1.1 Configuration won't launch Creating Collections in Classes what is best practises for sending out emails from .net? VS 2002 and Framework 1.0/1.1 SP upgrades How to disable event dll inside a dll? Adding function to Excel scheduled windows task |
|||||||||||||||||||||||