here is the website http://www.checker.freeproxy.ru/checker/
am trying to fill in the textbox using webbrowser how ever the textbox in webbrowser does not have any id at all here is the html source to the textbox.
<p class="lead">paste proxies you'd like to check below (100 max per time)</p>
<form method="post" action="/checker/" id="checker-form">
<fieldset>
<textarea rows="3"></textarea>
</fieldset>
<p id="checker-form-toolbar">
<button type="submit" class="btn btn-primary btn-block" data-checking-text="Checking proxies...">Check proxies</button>
</p>
i even tried
wb.Document.getElementById("textarea").focus
wb.Document.getElementById("textarea").innerText = Text4.Text
it dont work
Related
I am building a web application using the ASP.NET Core 3.1 MVC and Razor pages.
I am new to Razor pages.
I created a basic application using above. I created a registeration form having following three fields -
User name
User email address
Verification code
There are two buttons -
Send Code
Register
I am providing a feature in which the user can verify its email address before clicking on the "Register" button.
A verification code will be sent to the user to the email address, when user clicks on the "Send Code" button.
The user should then enter the code in the "Verification code" field and submit the form by clicking on the "Register" button.
Issue
When user clicks on the "Send Code" button, the code is send but the form data gets cleared i.e. "User name" and "User email address" fields values get erased. I used Ajax to call the "Send verification code" function. Following is the code -
Index.cshtml
<form class="form-horizontal" method="post">
<div class="form-row">
<label class="col-sm-2 control-label">Credentials</label>
</div>
<div class="form-group row">
<label asp-for="user.UserName" class="col-sm-2 col-form-label"></label>
<div class="col-sm-10">
<input type="text" asp-for="user.UserName" class="form-control" id="UserName"
name="UserName" placeholder="Enter Full Name"
value="">
</div>
</div>
<div class="form-group row">
<label asp-for="user.UserEmailAddress" class="col-sm-2 col-form-label"></label>
<div class="col-sm-10">
<input type="text" asp-for="user.UserEmailAddress" class="form-control"
value=""
name="UserEmailAddress" placeholder="Enter Email Address" id="UserEmailAddress">
<div class="form-inline">
<button id="btn1"
class="btn btn-primary mb-sm-1">
#Model.EmailVerifCodeLabel
</button>
<div id="grid" class="col">
<input type="text" asp-for="user.EmailVerifCode"
class="form-control" id="Emailverifcode" placeholder="Enter code">
</button>
</div>
</div>
</div>
</div>
<div class="form-group row">
<div class="col-sm-10">
<button type="submit" class="btn btn-primary">Register</button>
</div>
</div>
</form>
#section Scripts {
<script type="text/javascript">
$("#btn1").click(function () {
var UserName = $("#UserName").val();
var UserEmailAddress = $("#UserEmailAddress").val();
alert(UserName);
alert(UserEmailAddress);
$.ajax({
url: "#Url.Page("/Register")?handler=SendEmailVerificationCode",
method: "GET",
data: { UserName: UserName, UserEmailAddress: UserEmailAddress }
})
});
</script>
}
Index.cshtml.cs
public JsonResult OnGetSendEmailVerificationCode(string UserName, string UserEmailAddress)
{
Random generator = new Random();
String verifCode = generator.Next(0, 999999).ToString("D6");
_configuration.GetSection("ConnectionStrings").GetSection("DefaultConnection").Value;
HttpContext.Session.SetString("verifCode", verifCode);
_myemailSender = new EmailSender();
var emailresult = _myemailSender.SendEmailAsync(UserName, UserEmailAddress, verifCode, _configuration);
return null;
}
Question: What is the reason for the razor pages form data getting erased even after using Ajax call?
When user clicks on the "Send Code" button, the code is send but the form data gets cleared i.e. "User name" and "User email address" fields values get erased.
<button id="btn1" class="btn btn-primary mb-sm-1"> Model.EmailVerifCodeLabel</button>
You do not specify the type attribute for above <button> tag within your <form>, it would work as a submit button, which cause form submit and user inputs cleared.
To fix it, you can try to explicitly specify type="button" for btn1 button.
<button id="btn1" type="button"
class="btn btn-primary mb-sm-1">
#Model.EmailVerifCodeLabel
</button>
Or call preventDefault() method to prevent it from submitting a form.
$("#btn1").click(function (evt) {
evt.preventDefault();
var UserName = $("#UserName").val();
//...
I have a html view and this view displays list of elements. All elements have two buttons (edit and delete). When I click on delete all is working correctly but when I click on edit new view is not displayed. When I want to enter my direct url to edit it, all is working...
This is fragment of my code:
<div class="container">
<!-- topics -->
<div class="row topic" th:each="user : ${users}">
<div class="col-4">
<p>
<div class="input-group-addon" style="width: 2.6rem"><i class="fa fa-at"></i></div>
<a class="title " th:href="#{'/user/' + ${user.id}}" th:text="${user.email}"></a>
</p>
</div>
<div class="col-4">
<p>
<div class="input-group-addon" style="width: 2.6rem"><i class="fa fa-user"></i></div>
<a class="title " th:href="#{'/user/' + ${user.id}}" th:text="${user.fullName}"></a>
</p>
</div>
<div class="col-2">
<form action="#" th:action="#{'/user/drop/{id}'(id=${user.getId()})}" th:method="delete" >
<input type="hidden" name="_method" value="delete" />
<button type="submit" class="btn btn-danger">Usuń użytkownika</button>
</form>
</div>
<div class="col-2"></div>
<!--My failed button-->
<button type="submit" class="btn btn-warning" th:href="#{'/user/edit/' + ${user.id}}">Edycja</button>
</div>
</div>
</div>
A <button> has no href attribute. What you're looking for is a "link" (an <a> "anchor" tag to be specific):
<a class="btn btn-warning" th:href="#{'/user/edit/' + ${user.id}}">Edycja</a>
The reason your other button "works" is because it's part of a <form> and it submits that form. It doesn't follow any kind of href attribute. You could also make this button part of a form, but that doesn't appear to be the intended functionality. The intended functionality here is to direct the user to a new page, so a link is appropriate.
I have a form in razor page with 2 button.
<form method="post" class="form-group ">
<div class="form-group col-md-3">
<div class="input-group">
<input asp-for="DoctorViewModel.NationalCode" class="form-control" type="text" maxlength="10" required onblur="">
<div class="input-group-append">
<button class="btn btn-outline-primary " asp-page-handler="GetInfo" >search</button>
</div>
</div>
<span asp-validation-for="DoctorViewModel.NationalCode"></span>
</div>
.
.
<div class="form-group col-md-2">
<label asp-for="DoctorViewModel.Name" class="col-form-label"></label>
<input asp-for="DoctorViewModel.Name" class="form-control" type="text" maxlength="50" required>
<span asp-validation-for="DoctorViewModel.Name"></span>
</div>
.
.
.
.
<input type="submit" class="btn btn-success" value="Save"/>
</form>
and when click on search button i wants to load form info from a handler.
but when click this button get validation error.
How i can disable validation check for only search button. in asp.net form i used CauseValidation=false.
To skip validation while still using a submit-button, you can try to add the attribute formnovalidate :
<button class="btn btn-outline-primary" formnovalidate asp-page-handler="GetInfo">search</button>
The default type for a button is to submit the form it is contained within in most browsers.
You simply need to add a type of button and this should stop the submit and therefore the automatic validation will not trigger.
<button class="btn btn-outline-primary " type="button" asp-page-handler="GetInfo" >search</button>
am facing a weird issue with Invisible recaptcha. After 2 minutes when Recaptcha is getting expired its throwing script error "Object not found". Even tried using WidgetID but showing the same behavior. The only difference is I have an extra step in between the Recaptcha submit and my form submit. After successful recaptcha Submit on a button click a Pop up div opens on the page and the final submit happens on the click of pop up div submit button. All the submit process is working properly but when captcha expires in case form is left as idle for more than 2 minutes over the pop up div then it throws the error. Below is the code snippet:
<div>
<div>
...................
<div class="form__group">
<label class="text captcha"></label>
<div class="g-recaptcha" data-badge="inline" data-sitekey="{$CaptchaWebsiteKey}" data-size="invisible" data-expired-callback="validateExpire" data-callback="onSubmit"></div>
</div>
<div class="form__group">
<input id="btnPopUp" type="submit" class="btn btn--primary btn--full btn--xs-full" value="Submit your details"/>
</div>
</div>
</div>
<div id="modal" style="visibility:hidden;" class="modal">
<div class="modal-content">
<div class="modal-space">
...................
<div class="modal-space1">
<input type="submit" id="btnSubmit" value="Submit" class="modal-btn modal-space2 btn btn--primary btn--xs-full" disabled="true"/>
<input type="submit" value="Cancel" onclick="return closePopup();" class="modal-btn modal-space2 btn btn--primary btn--xs-full" />
</div>
</div>
</div>
</div>
<div class="overlay"></div>
<script language="javascript" type="text/javascript">
onload();
function onload() {
var element = document.getElementById('btnPopUp');
element.onclick = validate;
}
var captchaResponse='';
function onSubmit(response){
captchaResponse = response;
openPopup();
}
function validateExpire() {
grecaptcha.reset();
captchaResponse='';
}
</script>
Can anyone help regarding this issue? Thanks in advance.
I'm using bootstrap validator to validate the form in my react app, facing issues like the submit button is disabled but still clickable in the form, I want to make the button non clickable until the form gets validated. I added the disabled property but its not getting enabled once the form is valid.Below is my code.. Can anyone help here
<form data-toggle="validator" role="form">
<div className="form-group">
<div className="col-xs-5" id="form" style={{display:'none'}}>
{this.renderForm(this.props.fld_dtl_da)}
<button type="button" className="btn btn-default" onClick={this.ClearForm}>Clear</button>
<button type="submit" disabled='disabled' className="btn btn-primary" onClick={this.HandleClick}>Submit</button>
<br/><br/>
</div>
<div id="url" class="alert alert-info" style={{display:'none'}}>
<Confirmation message={this.state.message}/>
</div>
</div>
</form>