How to set value of hidden field in vb.net - vb.net

I need to set the value 12, which is defined as Public PageSize As Integer = 12 in aspx page, to the hidden field in vb.net.I defined hidden field as :
<asp:HiddenField id="ivar" runat="server" Value="<%= PageSize %>"/>.
After running the code and took view source it is just <input type="hidden" name="ivar" id="ivar" value="<%= PageSize %>" />.Not got as <input type="hidden" name="ivar" id="ivar" value="12" />

Use single quotes instead of double:
value='<%= PageSize %>"/>'

<asp:HiddenField id="ivar" runat="server" Value="<%#Eval("PageSize")%>"/>
plz try this

Related

get LoginName string value

I am using VB.NET and trying to get the value in the control LoginName1. I need this in string value for a parameter. I am not sure how to get this. I have tried the following which returns "system.web.UI.WebControls.LoginName". Dim txt As LoginName = DirectCast(LoginName1.FindControl("LoginName1"), LoginName)
<div style="float: left">
Welcome
<asp:LoginName ID="LoginName1" runat="server" Font-Bold="true" />
<asp:LoginStatus ID="LoginStatus1" runat="server" />
</div>

JSSOR with ASP.NET dynamic image

Here is my HTML Code that i am using
<div u="slides">
<div>
<asp:SqlDataSource ID="1" runat="server" ConnectionString="<%$ ConnectionStrings:constr %>" SelectCommand="SELECT Image FROM Gallery"></asp:SqlDataSource>
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="1">
<ItemTemplate>
<img u="image" src="<%# "image.ashx?Id="+ Eval("Id") %>" />
</ItemTemplate>
</asp:Repeater>
</div>
The Generic Handler .ashx for the image is THIS
My Issue is that on the Slide, only the last image uploaded come out.
For example, if i uploaded 5 images, only the fifth last uploaded image come up on the slider and it remains static.
I have tested the same generic Handler. it works normal for another slider.
am i missing something.
P.S - the Jssor scripts and css are all in their default values.
nothing was edited.
You placed all images in a single slide.
Please create slide for every image as below.
<div u="slides">
<asp:SqlDataSource ID="1" runat="server" ConnectionString="<%$ ConnectionStrings:constr %>" SelectCommand="SELECT Image FROM Gallery"></asp:SqlDataSource>
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="1">
<ItemTemplate>
<div>
<img u="image" src="<%# "image.ashx?Id="+ Eval("Id") %>" />
</div>
</ItemTemplate>
</asp:Repeater>
</asp:SqlDataSource>
</div>

How to update a record using SQL in ASP

So I'm trying to update a record within a table I created. The form processes but for some reason I don't see the table columns updated. The HTML form is
<form action="divProgramProcess.asp?div=<% =divrec %>" id="countInput" class="contact_form">
<input type="text" name="Shipment_Current" id="Shipment_Current" value="<% =Shipment_Current %>" />
<input type="text" name="Couch_Current" id="Couch_Current" value="<%= Couch_Current %>" />
<input type="text" name="Person_Available_Current" id="Person_Available_Current" value="<%= Person_Available_Current %>" />
</form>
The code within divProgramProcess.asp is
<%
divrec = request.QueryString("div")
Set rstest = Server.CreateObject("ADODB.Recordset")
rstest.locktype = adLockOptimistic
sql = "SELECT top 1 * FROM CensusFacility_Records_Last WHERE Count = '1239' "
rstest.Open sql, db
%>
<body>
<%
Shipment_Current = request.form("Shipment")
Couch_Current = request.form("Couch")
Person_Available_Current = request.form("Person_Available")
rstest("Shipment") = Shipment_Current
rstest("Couch") = Couch_Current
rstest("Person_Available") = Person_Available_Current
rstest.update
Response.Redirect("chooseScreen.asp")
%>
If you have some information you know you're going to pass, you may find it easier to just set it as a hidden input.
For example, instead of what you're doing above, do this with your form:
<form action="divProgramProcess.asp" id="countInput" class="contact_form">
<input type="text" name="Shipment_Current" id="Shipment_Current" value="<% =Shipment_Current %>" />
<input type="text" name="Couch_Current" id="Couch_Current" value="<%= Couch_Current %>" />
<input type="text" name="Person_Available_Current" id="Person_Available_Current" value="<%= Person_Available_Current %>" />
<input type="hidden" name="div" value="<% =divrec %>" />
</form>
And pull the value of div from the Request.Form collection.

TextBox showing past entries

I can not get the textbox past entries to go away using the aspx.vb behind page ( can do it on aspx page) Example below
I have tried both
txt.AutoCompleteType = AutoCompleteType.Disabled
txt.ViewStateMode = UI.ViewStateMode.Disabled
add autocomplete="off" attribute to textbox
<asp:TextBox Runat="server" ID="Textbox1" autocomplete="off"></asp:TextBox>
or add to to from tag
<form id="Form1" method="post" runat="server" autocomplete="off">
using code behind
Textbox1.Attributes.Add("autocomplete", "off");

accessing <input type="text"> value at codebehind

i have a small form on SharePoint application page:
<form method="post" id="registration-form" action="default.aspx" class="form-general cf" data-querycompletion-url="ajax/searchinstant.aspx">
<input type="text" id="name" name="name" placeholder = "Your name" runat="server" />
<input type="text" id= "company" name="company" placeholder= "Your company" runat="server"/>
<input type="text" id="srchtxtx" class="search" name="visitor" placeholder="visitor" runat="server" />
<input name="btnConfirm" id="Submit1" class="right" value="register" type="submit" runat="server" /></form>
At codebehinde of default.aspx, i want to access values as:
string val1 = name.value;
string val2 = company.value;
string val3 = srchtxtx.value;
But the above returns empty string in val1, val2 nd val3 respectively. But if I remove runat = "server" from <input> tags, then i can access values successfully as:
string val1 = Request.Form["name"];
string val2 = Request.Form["company"];
string val3 = Request.Form["visitor"];
The question is why it returns empty string values when I use runat = "server" in <input> tags ??
Due to some reasons, I could not remove runat = "server" from <input> tags.
Is there any other way to access <input> values at codebehind while assuming runat = "server" attribute in <input> ??
I am also restricted not to use <asp:TextBox> control.
As I hinted in html form submitted with null values, this is because the form does not runat="server" so the postback data is not processed by asp.net, i.e. properties of srchtxtx etc are not populated.
However html elements are still given unique ids on the page, so you cannot just do Request.Form["srchtxtx"];
To get around this, you can use the UniqueID of the input element to get the posted back value:
HTML
<form method="post" id="registration-form" action="default.aspx" class="form-general cf" data-querycompletion-url="ajax/searchinstant.aspx">
<input type="text" id="srchtxtx" name="srchtxtx" runat="server" />
<input name="btnConfirm" id="Submit1" class="right" value="register" type="submit" runat="server" />
</form>
C#
protected void Page_Load(object sender, EventArgs e)
{
string val1 = srchtxtx.Value; // always ""
string val2 = Request.Form["srchtxtx"]; // always null
string val3 = Request.Form[srchtxtx.UniqueID]; // input value
}