Click here to Skip to main content
15,888,733 members
Home / Discussions / ASP.NET
   

ASP.NET

 
SuggestionRe: Regarding querystring Pin
Richard MacCutchan13-Jun-17 5:07
mveRichard MacCutchan13-Jun-17 5:07 
AnswerRe: Regarding querystring Pin
ZurdoDev15-Jun-17 2:56
professionalZurdoDev15-Jun-17 2:56 
AnswerRe: Regarding querystring Pin
John C Rayan19-Jun-17 3:34
professionalJohn C Rayan19-Jun-17 3:34 
QuestionLock down the URL of an application for single device Pin
Schatak12-Jun-17 22:14
professionalSchatak12-Jun-17 22:14 
AnswerRe: Lock down the URL of an application for single device Pin
Afzaal Ahmad Zeeshan12-Jun-17 22:58
professionalAfzaal Ahmad Zeeshan12-Jun-17 22:58 
AnswerRe: Lock down the URL of an application for single device Pin
Deepak Vasudevan15-Jun-17 0:52
Deepak Vasudevan15-Jun-17 0:52 
GeneralRe: Lock down the URL of an application for single device Pin
Richard Deeming15-Jun-17 1:45
mveRichard Deeming15-Jun-17 1:45 
QuestionProgramatically click a button using http POST request Pin
Prasadaknair10-Jun-17 8:15
Prasadaknair10-Jun-17 8:15 
Please help me... I am stuck up with http post using http request.

I have an asp.net applicaton which is hosted locally in IIS(http://localhost/TestWebPage/Default.aspx) and here is the markup for Default.aspx;

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>Test Web Page</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>

<script type="text/javascript">       

    function showImage() {
        alert('hi');
    }
</script>    
</head>
<body>  
<form id="imageForm" name="imageForm" method="post" action="Default.aspx" >
    <input type="text" name="showImage" value="false" />
    <input type="submit" name="refresh" value="submit" onclick="showImage();" />
</form>
</body>
</html>
My Default.aspx.cs ;

protected void Page_Load(Object Source, EventArgs E)
{
// contains no code
}   
I have a separate c# application which tries to simulate the button click of "refresh" via http post to Default.aspx, here is the code;

string url = "http://localhost/TestWebPage/Default.aspx";
string postDataStr = "showImage=true";
postDataStr += "&refresh=submit";

byte[] postData = Encoding.ASCII.GetBytes(postDataStr);

HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength = postData.Length;
req.Proxy = WebRequest.DefaultWebProxy;

using (var reqStream = req.GetRequestStream())
{
    reqStream.Write(postData, 0, postData.Length);
}

HttpWebResponse response = (HttpWebResponse)req.GetResponse();
Stream responseStream = response.GetResponseStream();
StreamReader reader = new StreamReader(responseStream, Encoding.Default);
string pageContent = reader.ReadToEnd();

string status = ((HttpWebResponse)response).StatusDescription;

reader.Close();
responseStream.Close();
response.Close();
My aspx page is already opened in a chrome browser. When the above code is executed, I want the javascript alert in the showImage() function to be displayed in the Default.aspx page in the same browser window itself.

Unfortunately its not happening now... am I missing anything? or is there any good approach to simulate the button click using separate c#?

Please guide.

Answer[Repost] Programatically click a button using http POST request Pin
Richard MacCutchan10-Jun-17 9:16
mveRichard MacCutchan10-Jun-17 9:16 
QuestionHow to run jquery in visual studio 2008 asp.net web application project Pin
HedwigO10-Jun-17 1:36
HedwigO10-Jun-17 1:36 
AnswerRe: How to run jquery in visual studio 2008 asp.net web application project Pin
F-ES Sitecore11-Jun-17 23:11
professionalF-ES Sitecore11-Jun-17 23:11 
GeneralRe: How to run jquery in visual studio 2008 asp.net web application project Pin
HedwigO13-Jun-17 4:56
HedwigO13-Jun-17 4:56 
GeneralRe: How to run jquery in visual studio 2008 asp.net web application project Pin
Richard Deeming13-Jun-17 5:04
mveRichard Deeming13-Jun-17 5:04 
GeneralRe: How to run jquery in visual studio 2008 asp.net web application project Pin
HedwigO13-Jun-17 5:22
HedwigO13-Jun-17 5:22 
GeneralRe: How to run jquery in visual studio 2008 asp.net web application project Pin
Richard Deeming13-Jun-17 5:27
mveRichard Deeming13-Jun-17 5:27 
QuestionWebAPI: When to use multiple endpoint or multiple route for single action Pin
Mou_kol8-Jun-17 22:54
Mou_kol8-Jun-17 22:54 
AnswerRe: WebAPI: When to use multiple endpoint or multiple route for single action Pin
Richard MacCutchan9-Jun-17 0:24
mveRichard MacCutchan9-Jun-17 0:24 
AnswerRe: WebAPI: When to use multiple endpoint or multiple route for single action Pin
F-ES Sitecore9-Jun-17 3:58
professionalF-ES Sitecore9-Jun-17 3:58 
GeneralRe: WebAPI: When to use multiple endpoint or multiple route for single action Pin
Mou_kol12-Jun-17 3:42
Mou_kol12-Jun-17 3:42 
QuestionWeb API: different way of attribute routing Pin
Mou_kol8-Jun-17 5:05
Mou_kol8-Jun-17 5:05 
Questionuser control Pin
caradri8-Jun-17 3:01
caradri8-Jun-17 3:01 
QuestionQuestion regarding asp.net web forms Pin
Member 132480908-Jun-17 1:52
Member 132480908-Jun-17 1:52 
AnswerRe: Question regarding asp.net web forms Pin
Afzaal Ahmad Zeeshan8-Jun-17 5:38
professionalAfzaal Ahmad Zeeshan8-Jun-17 5:38 
GeneralRe: Question regarding asp.net web forms Pin
ZurdoDev8-Jun-17 5:43
professionalZurdoDev8-Jun-17 5:43 
GeneralRe: Question regarding asp.net web forms Pin
Afzaal Ahmad Zeeshan8-Jun-17 5:49
professionalAfzaal Ahmad Zeeshan8-Jun-17 5:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.