Hi,

At first I'm really sorry for my bad English :icon_redface:

I really want to simulate a ImageButton click for an ASP.NET (.aspx) file via curl (or simplate HTML file, but I very tries for it and finally I didn't get it!

More explain...
I have this snippet code on Default.aspx.cs that I want to simulate it through curl.

protected virtual void MyIBtn_Click(object sender, ImageClickEventArgs e)
    {
        Response.Write("Image Button Clicked!");
    }

Now I want to get this result via curl. I try this but this is not working!

<?php
$aspx = curl_init('http://mysite.com/MyWeb/Default.aspx');
curl_setopt($aspx, CURLOPT_USERAGENT, 'Firefox');
curl_setopt($aspx, CURLOPT_RETURNTRANSFER, true);
curl_setopt($aspx, CURLOPT_POST, true);
curl_setopt($aspx, CURLOPT_POSTFIELDS, array(
	'MyIBtn_x' => '0',
	'MyIBtn_y' => '0'
));
echo curl_exec($aspx);
curl_close($aspx);
?>

and this is HTML that I want to simulate it

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>
	Untitled Page
</title></head><body>
<form name="ctl01" method="post" action="http://mysite.com/MyWeb/Default.aspx" id="ctl01">
<div>
<input name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTEzODk5NzQ4MWQYAQUeX19Db250cm9sc1JlcXVpcmVQb3N0QmFja0tleV9fFgEFBk15SUJ0bmXldSN54bOFxnGm5yZDVvjTHfvk" type="hidden">
</div>

<div>

	<input name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWAwKghvXDAQK4ookeArro0fgO0i7R2lalHTpHY1Qz9NjPEsU9qDo=" type="hidden">
</div>
	<input name="MyIBtn" id="MyIBtn" src="" style="border-width: 0px;" type="image">
</form> 
</body></html>

When I investigate for this problem I understood it's maybe for difference sender because for real ImageSubmitButton it's System.Web.UI.WebControls.ImageButton while for another it's not!

Note: I haven't access to source ASP.NET file on the server.

Thanks.

Everybody doesn't any solution for this? It's very important for me.

WOW! If figured out this problem! I used these postfields.

curl_setopt($aspx, CURLOPT_POSTFIELDS, array(
	'MyIBtn.x' => '0',
	'MyIBtn.y' => '0'
));

Just put "." instead of "_" and problem solved as easy!!!

this is helpful and looks like what i need. is the array corresponding to the "name" or the "id"?

<input name="MyIBtn" id="MyIBtn"

like say for example it's

<input name="MyIBtn" id="My_Button"

How would it be

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.