There is a HTML code, in another website :
<form action="down.php" enctype="multipart/form-data" method="post">
<input type="hidden" name="mid" id="mid" value="pg/K/c3scJubYvZj8UI=" />
<span><input class="btnff" type="submit" value="downloadd" /></span>
</form>
I want to download with Watin and c sharp :
WatiN.Core.Button btn1 = browser1.Button(Find.ByValue("downloadd")) as WatiN.Core.Button;
btn1.Click();
When I click on it, download start with IDM(Internet download manager).
The Link does not exist in Source code, even after I click on Button.
How can I get Link with Watin(Not IDM) and download with c sharp to save in a specific folder?
Related
Following is the HTML form code, for uploading text value and a JPEG file.
<html>
<head></head>
<body>
<form action="https://mywebsiteforexample.com/" method="post" enctype="multipart/form-data">
<input type="text" name="id" value="01"/>
<input type="file" name="image">
<input type="submit" value="send">
</form>
</body>
</html>
Problem is whenever I have to upload the file on server, I need to manually browse the file to upload it. I want to write the same code in C# so when I run the code it itself select the file by path given, and upload the file so I don't need to browse and select the file manually. Is it possible.
You don't need to write code that fills input elements (if you want, use Selenium with C# driver). Just simulate POST action from simple console application using for e.g. HttpClient.
There are plenty of questions on SO how to do it, e.g. C# HttpClient 4.5 multipart/form-data upload
I'm using jansy bootstrap to replace the asp.net FileUpload. I've successfully retrieved the file using HttpPostedFile with the help of this answer:
HttpPostedFile image = Request.Files["myFile"];
Now, how do I allow multiple files to be selected? With the asp.net FileUpload it was simply adding AllowMultiple="True" parameter and then in the code behind I simply looped through:
foreach (var image in FileUpload1.PostedFiles)
{...}
How do I do this with a custom control? THis is my current html (which is the first Image Upload Widget example):
<div class="fileinput fileinput-new" data-provides="fileinput">
<div class="fileinput-preview thumbnail" data-trigger="fileinput" style="width: 200px; height: 150px;"></div>
<div>
<span class="btn btn-default btn-file"><span class="fileinput-new">Select image</span><span class="fileinput-exists">Change</span>
<input type="file" id="myFile" name="myFile"></span>
Remove
</div>
</div>
You can add multiple attribute and set its value to multiple to allow select of multiple files
<input type="file" id="myFile" name="myFile" multiple="multiple">
I'm not am experienced asp.net user so hopefully this is fairly easy as it is in php.
I am trying to receive modified html of a div that is modified by the user of a webpage and save it back to a database.
When I click the save button the old(previous) html data is being displayed not the new html data that I want saved.
html:
<asp:LinkButton ID="saveButton" type="button" CssClass="clickable" runat="server" Text="Save" OnClick="SaveButtonClicked" />
<div id="formContainer" class="form-container" runat="server">
<div class="form-header">Form Title</div>
<ul class="section-sortable"></ul>
<div class="form-footer">
<input type="submit" value="Submit form" />
</div>
</div>
c#
protected void SaveButtonClicked(object sender, EventArgs e)
{
//Returns old html when it should return the new modified html?
Debug.Write(this.formContainer.InnerHtml);
}
The html modification code is not shown here but the html is being modified..
Only solution I found was to listen to both the Click and ClientClick events copy the Inner HTML from the div to a hidden input control and then the data is visible on the click event.
Thanks for checking.
I am building a web application using angularjs. i have two buttons one will do a Ajax post to server using angularjs and the other will to a normal html post to server. the reason i want the second one to do a direct post to server is that i want to generate an excel document on server and return it tp user to download on response.
please how can i disable angularjs from capturing my form submit for the secont submit button
I'd say that the simplest way is to change the button that shouldn't post the form to not be a form button, but another element that doesn't have that default behaviour. That is, change this:
<form>
<input type="text">
<input type="submit" ng-click="doStuff()" value="Ajaxy things">
<input type="submit" value="Real post">
</form>
to:
<form>
<input type="text">
<a ng-click="doStuff()">Ajaxy things</a>
<input type="submit" value="Real post">
</form>
And style the a to look like a button.
This a html code in site that i want to use it in my web browser control C# :
<form name="frmWorkBookPrintTerm" action="WorkBookPrintTerm.asp" target="_blank" method="post">
<hr width="90%">
<input type="Hidden" name="strTermCode" value="912">
<input type="Hidden" name="strStudentCode" value="896325605">
<input type="Button" onclick="javascript:document.frmWorkBookPrintTerm.submit();" value="...">
<hr width="90%">
</form>
But It is not working. When i want to go ".../WorkBookPrintTerm.asp" directly website says you did illegal job and otherwise web browser control is not working.
Thank You.