I create html element from database :
Dim table As String = "<form method='POST'>"
table &= "<input type='textbox' value='123' id='txtText'/>"
table &= "<input type="sumbit" text='Submit' /></form>"
When i click button submit, I want get value textbox with VB.NET
You just need to use RUNAT = "SERVER"
<form method='POST'>
<input type='textbox' value='123' id='txtText'/>
<input runat="SERVER" type="hidden" name="txtHidden" value="123" />
</form>
You need to set the value to hidden text, use runat = "SERVER"and get the value on server-side.
Related
I have this issue. I am trying to fill forms of this website using robobrowser. My code in python is below:
new_CRTS_DR3_beta_url = 'http://crts.iucaa.in/CRTS/'
browser = RoboBrowser()
browser.open(new_CRTS_DR3_beta_url)
form = browser.get_form(action='/CRTS/imaging')
form['query_input'].value = '332.64277 -22.66323'
form['radius'].value = '0.1'
However, 'query_input' does not have the attribute value before I fill the input, and when the input is filled the attribute value appears and is set with the input value. The HTML code looks like:
Before when it is empty:
<input class="form-control input-sm" type="hidden" id="query_input"
name="query_input">
After setting an input:
<input class="form-control input-sm" type="hidden" id="query_input" name="query_input" value="332.64277,-22.66323">
Thank you for any help!
when I add the name attribute to a field form in Yii , the field content is not saved in DB
the following works,
echo $form->textField($model,'country'); ?>
it generates the html code
<input name="RegistrationForm[country]" id="RegistrationForm_country" type="text" maxlength="50" />
the following does not work,
echo $form->textField($model,'country', array('name'=>'country'); ?>
it generates the html code
<input name="country" id="country" type="text" maxlength="50" />
Any idea?
The field name="RegistrationForm[country]" is required if you are using
$model->attributes = $_POST['RegistrationForm'];
to set the attributes in the controller.
If you want to use a custom name like name="country", you will have to manually set the value of the model yourself:
$model->attributes = $_POST['RegistrationForm'];
$model->country = $_POST['country'];
I have used HTTPClient to connect to a website and I can successfully access required data from the website using jsoup.
I have the following code from which I need to extract the submit button info.
<form method="POST" action="test.jsp" >
<font size="2">
<input type="hidden" name="num" id="num" value=123 >
<input type="hidden" name="iec" id="iec" value=456 >
<input type="submit" onclick=" return check();" value="Print" name="B1">
</font>
</form>
How can I access the value and name of the submit button?
You can access those values using the attr(String attribute) method of Element. For example:
String html = "<form method=\"POST\" action=\"test.jsp\" >"
+ "<font size=\"2\">"
+ "<input type=\"hidden\" name=\"num\" id=\"num\" value=123 >"
+ "<input type=\"hidden\" name=\"iec\" id=\"iec\" value=456 > "
+ "<input type=\"submit\" onclick=\" return check();\" value=\"Print\" name=\"B1\">"
+ "</font>"
+ "</form>";
Document doc = Jsoup.parse(html);
Element bttn = doc.select("input[type=submit]").first();
String value = bttn.attr("value"); // will be Print
String name = bttn.attr("name"); // will be B1
I have a form with 3 text fields and 3 checkboxes. I had implemented VB Script validation so if a user submits the form and leaves something empty, the user will get back to the form WHILE having the fields filled in already. That said, this is not working for the chackboxes.
this is the code I am using for the checkboxes I am doing code in the value""
<input type="checkbox" name="ClaimSection_ActivityProof" id="ClaimSection_ActivityProof" value="<%=Request.Form("ClaimSection_ActivityProof")%>" style="width:20px" />
<input type="checkbox" name="ClaimSection_InvoicesPayableByPartner" id="ClaimSection_InvoicesPayableByPartner" value="<%=Request.Form("ClaimSection_InvoicesPayableByPartner")%>" style="width:20px" />
<input type="checkbox" name="ClaimSection_InvoicesPayableByGFI" id="ClaimSection_InvoicesPayable" value="<%=Request.Form("ClaimSection_InvoicesPayable")%>" style="width:20px" />
To cut the sotry short, if a user checks 2 checkboxes, submits the form, and when he is redirected back to the form again, the checkboxes will remain checked. How I can do this please?
name ( or group ) the checkboxes by the same name, ( I assume they all are related ClaimSection matter)
So ,you can name them all as "ClaimSection". Just make sure you assign each one its own unique values!
Example;
<input type='checkbox' name='ClaimSection' value='ActivityProof'>
<input type='checkbox' name='ClaimSection' value='InvoicesPayableByPartner'>
<input type='checkbox' name='ClaimSection' value='InvoicesPayableByGFI'>
With this naming, if your user checks more than 2 checkboxes, you will get the corresponding values in a comma separated fashion.
So, if your user checks the last 2 checkboxes, you will get "InvoicesPayableByPartner,InvoicesPayableByGFI" in return.
Now that you know this, it won't be hard to set up a bunch of if branches to handle the checked vs not checked matter by comparing against what you got in the request("ClaimSection")
Something like the following can get you in the right direction..
dim submitted_ClaimSections
submitted_ClaimSections = request("ClaimSection")
submitted_ClaimSections = "," & submitted_ClaimSections & ","
//handle the ActivityProof checkbox checked_or_not =""
if instr(submitted_ClaimSections,"," & "ActivityProof" & ",")>0 then
checked_or_not = "checked"
end if
Response.write "<input type='checkbox' name='ClaimSection' value='ActivityProof' " & checked_or_not & "> ActivityProof"
//handle the InvoicesPayableByPartner checkbox checked_or_not =""
if instr(submitted_ClaimSections,"," & "InvoicesPayableByPartner" & ",")>0 then
checked_or_not = "checked"
end if
Response.write "<input type='checkbox' name='ClaimSection' value='InvoicesPayableByPartner' " & checked_or_not & "> InvoicesPayableByPartner"
//handle the InvoicesPayableByGFI checkbox checked_or_not =""
if instr(submitted_ClaimSections,"," & "InvoicesPayableByGFI" & ",")>0 then
checked_or_not = "checked"
end if
Response.write "<input type='checkbox' name='ClaimSection' value='InvoicesPayableByGFI' " & checked_or_not & "> InvoicesPayableByGFI"
I think you should post back your form data. Try following links:
http://www.motobit.com/tips/detpg_post-binary-data-url/
http://www.tek-tips.com/viewthread.cfm?qid=1281365
These links provides some example code sending form data with post method. Unfortunatly I haven't set up an IIS, so I couldn't try those examples. At the first view the idea can work.
The value attribute is not really relevent to making sure the checboxes retain their checked state on load / postback.
To do this, you need to check if they where checked on submit ("on" in request.form), if "on" then set checked="checked".
Example:
<%
if len(request.form("ClaimSection_ActivityProof")) > 0 then
ClaimSection_ActivityProof_Checked = " checked=""checked"""
else
ClaimSection_ActivityProof_Checked = ""
end if
%>
<input type="checkbox" name="ClaimSection_ActivityProof" id="ClaimSection_ActivityProof" <%=ClaimSection_ActivityProof_Checked %> style="width:20px" />
Hope that makes sense.
J.
i have simple html page with 3 textboxes.
<form id="form1" method=get action="http://mysite.com/default.aspx" runat="server">
<div>
<input id="name" type="text" value="Amy" />
<input id="email" type="text" value="amy#jf.com"/>
<input id="phone" type="text" value="2125552512" />
</div>
<input id="Submit1" type="submit" value="submit" />
</form>
Now when it loads default.aspx i have this code in the vb backend on page_load.
Dim tbName As TextBox = Page.FindControl("Name")
Dim tbPhone As TextBox = Page.FindControl("Phone")
Dim tbEmail As TextBox = Page.FindControl("Email")
If page.request("name") & "" <> "" AndAlso tbname IsNot Nothing Then
tbname.text = page.request("name")
End If
If page.request("email") & "" <> "" AndAlso tbEmail IsNot Nothing Then
tbEmail.text = page.request("email") & ""
end If
If page.request("phone") & "" <> "" AndAlso tbphone IsNot Nothing Then
tbPhone.text = page.request("phone") & ""
End If
The page loads but is these textboxes are empty. what am i doing wrong?
If you want to be able to access those controls serverside, you'll need to add the runat="server" attribute to each of them.
Also, the TextBox type you're referencing is the ASP.NET control, which you aren't using. What you'd be using, once you add the runat="server" tags is HtmlInputText.
You can use the TextBox type by using the TextBox ASP.NET control instead of the <input> elements:
<asp:TextBox ID="name" runat="server" Value="Amy" />
If all your ASP.NET page is doing is processing the request from the form, then there's no need to reference any textbox or input controls - it won't be possible since they don't exist as ASP.NET controls. All you need to do is read the values from Request.QueryString.
If the intent is for the inputs to be visible and/or editable once they're on the ASP.NET page, I'd recommend moving the HTML form into your ASP.NET page.
it is not like this that webform functionate.
First, your input in your form needs to be server control: ex <asp:TextBox runat="server" id="name" Text="value" />
Then in your codebehind file you do not have to go through Page.FindControl("YourInput") but only this.YourInput.Text