Getting Value from Client-side InputBox to .net variable

hi,

im doing a login page for our timekeeping. Since there's no msgbox available on asp.net, im doing it dynamically via javascript.
How do i Get the value frm a dynamically written javascript (such as inputbox) to a .net variable?
here's the logic of my program, user logs in hits the button and sub-routine Login will be fired, if user is late -- call Check_Late Sub, this is whre the client-side script was built -- then after that i wanted to be able to get the value from an inputbox.


'// if button login clicked
Sub Login(Sender As Object, E As EventArgs)
.... //codes for checking late...
'/// if late??
if late then
call Check_Late()
'// maybe i can have a variable here which gets the result from Prompt window?
'// is it possible??
end if
End Sub

'//called when late
Sub Check_Late(Sender As Object, E As EventArgs)
dim sb as New System.Text.StringBuilder
'//SINCE msgbox is not available, i'm writing it client-side, dynamically
sb.append("<script language=" & """" & "vbscript" & """" & ">")
sb.append(vbcrlf)
'// need a do while loop here so user cant exit Prompt Window without value
sb.append("do while xLate =" & """" & """")
sb.append(vbcrlf)
sb.append("xLate =InputBox(" & """" & "Please Enter Reason for Being Late" & """" & ")")
'sb.append(vbcrlf)
sb.append("loop")
sb.append(vbcrlf)
'//??????
'// i needed something here to get the value of xLate
'// using these codes that i have..
'//?????
sb.append(vbcrlf)

dim scriptString as string
scriptString += "<"
scriptString += "/"
scriptString += "script>"
sb.append(scriptString)
sb.append(vbcrlf)
RegisterClientScriptBlock("anything", sb.ToString())
End Sub
<form id=form1>
<input type=Hidden id="reason">
<asp:TextBox id="username" runat="server"></asp:TextBox>
<asp:TextBox id="password" runat="server"></asp:TextBox>
<asp:button id="button2" width="68" class="butt" style="cursor:hand" onclick="Login" runat="server" />
</form>

i'm really desperate on this one man... I needed Help :(
thanx and GodBless
0
carlod
7/29/2004 9:51:31 AM
asp.net.client-side 24353 articles. 1 followers. Follow

4 Replies
1232 Views

Similar Articles

[PageSpeed] 39

use a input hidden add runat="server" and set your value from your javascript in this field and get it in your code behind.
Jean-Francois Borie
"Jef"
0
jef06
7/29/2004 12:55:26 PM
could you please give me a sample code? i'm not very familiar with having a codebehind file, .net newbie.

thanx
0
carlod
7/30/2004 8:38:11 AM
The example I gave you in your other thread should work fine, it's the sort of thing I do all the time.

If there is somethign specific that you don't understand let us know and I'll see if I can help
"There is no such thing as a bug, just an unexpected feature."
0
Superfly1611
7/30/2004 10:57:13 AM
hi sir,

thanx for ur help, i'm putting my code here so maybe u can check where did i go wrong.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
<script language="VB" runat="server">
'// WHEN SUBMIT BUTTON CLICKED, THIS SUB-ROUTINE WILL EXECUTE
public sub Login( sender As Object, e As EventArgs )
'//
if ispostback then

'// THEN I HAVE SOME CODE HERE TO VALIDATE
'// IF YOU COME IN LATE... SO WHEN IT DOES
'// YOUR SUGGESTED CLIENT-SIDE CODE WILL BE RE-WRITTEN
'// BUT ON THE SERVER-SIDE AS FOLLOWS:
dim sb as New System.Text.StringBuilder

sb.append("<script language=" & """" & "javascript" & """" & ">")
sb.append(vbcrlf)

sb.append("xLate = prompt(""" & "Please Enter A Reason for Being Late" & """);")
sb.append(vbcrlf)
sb.append("formElement = document.getElementbyId(" & """" & "reason" & """" & "); ")
sb.append(vbcrlf)

sb.append("formElement.value = xLate;")
sb.append(vbcrlf)
'// SOMEHOW RE-SUBMITTING OF THE FORM
'// WITH THE BELOW CODE DOESN'T WORK..
'//
sb.append("document.form1.submit();")
sb.append(vbcrlf)

dim scriptString as string

scriptString += "<"
scriptString += "/"
scriptString += "script>"

sb.append(scriptString)
sb.append(vbcrlf)

RegisterClientScriptBlock("anything2", sb.ToString())
'//WRITE REASON VALUE
response.write ("my Reason : " & request.form("reason"))
end if
end sub
</script>

</head>
<body>
'// IF IT WILL RE-SUBMIT, IT WILL HAVE AN
'// OUTPUT VALUE SUCH AS THE ONE BELOW:
<%="My reason: <br>" & request("reason")%>

<form runat="server" id="form1" name="form1">
'//THE HIDDEN CONTROL AS U SUGGESTED
<input type="hidden" id="reason" name="reason" value="">

username: <asp:TextBox id="uid" runat="server" ></asp:TextBox><br>
password: <asp:TextBox id="pwd" runat="server" ></asp:TextBox>
'// WHEN THIS BUTTON IS CLICKED, SUB-ROUTINE LOGIN WILL BE FIRED.
<asp:button id="mybutt" width="68" onclick="Login" runat="server" />
</form>
</body>
</html>

I really appreciate ur help and thank you so much.. God Bless man.
0
carlod
8/2/2004 8:03:57 AM
Reply:

Similar Artilces:

Getting hidden variable value from server side in client side
hi,        I am struck in problem. I have a hidden field in my form and i am setting some value in that.         Now i wnt to use this value from client side but i m not able to retrieve it. All i am getting there is an object.         I feel the hidden field is not able to hold that value.         <input type="hidden" id="hdnVar" runat="server" />         in code behind      ...

how to get value from client side script Prompt window to a session var in .net
hi guyz, i hav a problem with getting a value from a client-side inputbox to a session var in .net. is this possible? however, when i click submit button this is the code that's triggered. dim sb as New System.Text.StringBuilder sb.append("<script language=" & """" & "vbscript" & """" & ">") sb.append(vbcrlf) sb.append(vbcrlf) sb.append("do while xLate =" & """" & """") sb.append(vbcrlf) '//prompt window, val...

Getting my client-side variable over to server-side
Ok so I have looked at a few posts on this subject and I can't quite figure out how to apply the idea to what I am doing here. I am using javascript to take amounts from 7 different textboxes and add them up on the fly, dropping the total in the 8th textbox. After they fill in that information they click button (postback) to continue throughout the form... what I need is for the "textboxTotalAmt" to move from client-side to server-side.  So I can access that total amount later in the form. Here is the Javascript piece... <script type="text/java...

How to get the Client side values in server side code.
Hi all, i have a proble i need to get the client side javascript values in C# code at server side. how can i pass those values? i am using version 1.1, i kno thatwe can use callback events mechnisam in 2.0 or ajax ,apart from that how we can pass? My problem is i need to stop the execution of the code based on after reciving values from the client   any ideas please???   Million thanks RamCheersRam MCP Hello Ram, a common approach is from javascript set an hidden field, then issue a postback. On the server-side, handle the post-back. Feel free to go deeper in your que...

Validation Controls in .NET ( Client side or server side?)
 i have a very basic question. We have all these validation controls in asp.net ( required field, range validator and others)..my question is the required field validator is a server side control. So does that mean that it does a post back?..is it client side or server side control  The only controls that post back are buttons and other inputs where you set AutoPostback="True", such as a dropdownlist or a textbox.  Another way of posting back is using an UpdatePanel and placing a trigger in it for a specified control and/or event. All controls are considered clien...

Jscript, moving from client-side to server-side (.NET)
Hey all I’m working translating a web-app written in client-side Jscript to run on the server-side as JScript.NET. Without needing to get too specific, I am using Jscript because the original page aggregated raw data to produce statistical results (this was done dynamically based on user 'sort-by' options). The final output is an html report that can be emailed. Because this is currently being done on the client side, as the raw data grows the load-time grows as well (to the point that has almost become unusable). I’m posting here to see if anyone has any experi...

passing client side variable value to server side
 i have a grid and  by click on the rows, the onrowclick event is fired on client side. I want to pass the row index to the server side. As there are not sessions variables in javascript so i am stuck to pass the row to the server side.. I have made a texbox and set its valueto the index in the onrowclick event but when refresh calls, the text box became empty as the value set is on client side, i want page to persistthe value,  How can i do that? Tel me some way passing the row index to the server side?? Hi, You can call GridView_SelectedIndexChanging event on row click ev...

Client side code to pass values to server side variable?
Hi there, I have ListBox_SelectedTextChanged() method that creates another list box in the runtime as follows: // Get Action Level List lbxActionLevel = new ListBox();lbxActionLevel.ID = "ddlA" + i.ToString(); lbxActionLevel.Width = 100; lbxActionLevel.Rows = 2;SqlDataReader dr = new BusinessLogicLayer().bllGetActionLevels(); lbxActionLevel.Items.Clear();while (dr.Read()) {ListItem lAction = new ListItem(); lAction.Text = dr.GetString(1).Trim();lAction.Value = Convert.ToString(dr.GetInt32(0)); lbxActionLevel.Items.Add(lAction); lbxActionLevel.SelectedIndex = 0; } I ...

When to use client side varidation and server side varidation in .net?
In .net or classic web application we can varidate user data either on client isde or server side. How to select which side varidate to be used? Thanks! Generally, I use both client and server validation. I make sure the input is in the correct format and reasonably valid on the client, then I verify the data on the server. The extent of validation also depends on the type of data that I need to validate.Here are a few references:Validating ASP.NET Server ControlsIntroduction to Validating User Input in Web FormsClient-Side Validation for ASP.NET Server ControlsSecurity Checklist...

communication between client side(java script) and server side in .net project
I have a question which is, when building a .net project, we are able to use server side code and client side code(java script). How do they communicate? Thanks Client Side coding works with the WebBrowser. So when ever you write client side code you have to keep browser compatability in your mind and you have to code. Server Side code works with Web Server (IIS) and it's ASPNET ISAPI's. The won't directly communicate with each other. But using AJAX you can all server side code from Client Side! Example article on Ajax@ http://www.devarticles.com/index2.php?option=content&task=...

.NET for client side?
Is this the idea of "Atlas" but using JavaScript rather than another technology? Atlas's goal is to abstract various browser implementations of DOM API and to ease out the developer's job to write rich client applications. Atlas hence makes use of the existing all-browser supported JavaScript to achieve this. Thanks for your reply.Let me convey my idea differently: I would like to author client side code using a class system. I recognise that Atlas is a technology for producing JS code, much in the same way that ASP.NET produces HTML for the browser.Will Atlas be m...

How can I set client side values as server side values?
Hi, Can anyone tell me how I can get client side values such as document.referrer, navigator.appName etc... into server side scripts? There are some client side values I'd like to set as session vars and insert into the db? How do I go about this? Thanks for any pointers Davlon PS (I'm using powersite 7.1.0.300) Pass them as page parameters, e.g., http://myserver/myurl?document.referrer=whatever&navigator.appName=yadayada Then, in your server-side script, just loop through the document.value array and get these values. -- pbm_hopethishelps, Roy Kie...

Client Side values to Server Side
What is the best way to transfer Client Side values to the Server side? For example I have a variable "var1" in javascript. var1 = "sample"; How can I acquire this value in the server side?  What is the best approach for this?  Barry to send the value to the server during a postback, you need to place the value in an input control.  You could consider using a hidden textbox for that purpose.Mike Banavige~~~~~~~~~~~~Need a site code sample in a different language? Try converting it with: http://converter.telerik.com/ In the JavaScrip...

Client-side values to server-side ?
Hi! My previous query is attached below: I have implemented the below mentioned implementation . 'listbox1' on 'webform1' shows all the values from 'webform2'. I have implemented it using javascript. I would like to know that to implement validation on 'webform1', I would require the values of 'listbox1' ,which are on the client-side , to move to the server-side . I think sending a querystring will be fine but how to implement it using javascript and code-behind(C#)? Your suggestion will be appreciated. Thanks and regards, ap.       My previous query: " I am stuck wi...

Web resources about - Getting Value from Client-side InputBox to .net variable - asp.net.client-side

Client-side - Wikipedia, the free encyclopedia
Client-side refers to operations that are performed by the client in a client–server relationship in a computer network . Typically, a client ...

Senior Search Manager - Client Side!!
... strategy insight for senior IT management - resources to understand and leverage information technology. Senior Search Manager - Client Side ...

Account Manager - Client Side - Previous Agency Experience Welcome!!
Computerworld Australia is the leading source of technology news, analysis and tools for IT decision makers, managers and professionals.

Media Sales Executive - Client Side!!
Technology news and reviews for business and home.

PPC Paid Search Manager - CLIENT SIDE
Defining Technology for Australia's IT Leaders. PPC Paid Search Manager - SEM - **CLIENT SIDE** Sydney CBD Location Client side!! SEM/PPC/Paid ...

How Basecamp Next got to be so damn fast without using much client-side UI
When we started working on Basecamp Next last year, we had much internal debate about whether we should evolve the existing code base or rewrite ...

Seven Tips for Pitching From the Client's Side of the Table
I had a chance to sit on the other side of the pitch table. Here is what I learned.

Client-side coding: How to prevent malicious use?
Applications that run on a user-controlled device cannot be perfectly protected.

The client side
... regarding the professionals you seek to assist. Even better if you possess that understanding yourself, having worked on the client side. I'm ...

Ecommerce traffic being hijacked by client side malware
According to new research 15 to 30 percent of eCommerce site visitors are infected with Client Side Injected Malware (CSIM) that causes them ...

Resources last updated: 2/5/2016 8:04:43 AM