help with value in asp.net

Get help on web editors (Frontpage, Dreamweaver) and web languages (HTML, ASP, PHP).
Post Reply
CesarePlay
Registered User
Posts: 10628
Joined: 26 Mar 2007, 02:00
Location: In the river of thoughts
Contact:

help with value in asp.net

Post by CesarePlay »

I need a value in asp.net to be ready in javascript. Can anyone help with this? I use vb.net 2003.
Image
User avatar
Ron2K
Forum Technical Administrator
Posts: 9050
Joined: 04 Jul 2006, 16:45
Location: Upper Hutt, New Zealand
Contact:

Re: help with value in asp.net

Post by Ron2K »

Your question is too vague to receive a useful answer; please define it better.
Kia kaha, Kia māia, Kia manawanui.
CesarePlay
Registered User
Posts: 10628
Joined: 26 Mar 2007, 02:00
Location: In the river of thoughts
Contact:

Re: help with value in asp.net

Post by CesarePlay »

Ok. I have created a function in the code behind called checkdata() . This function checks what sector was selected.

I have also created a javascript function in the html part which calls this function and the checks to see if the fields have been selected. At the moment the problem is the values are not corresponding. The error only occurs when I try save the data and not before.
Image
RuadRauFlessa
Registered User
Posts: 20576
Joined: 19 Sep 2003, 02:00
Location: Bloodbank

Re: help with value in asp.net

Post by RuadRauFlessa »

sudo code please
:rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock:
Spoiler (show)
Intel Core i7-2600k @ 3.4GHz
Corsair Vengence 2x4GB DDR3 2000MHz
Thermaltake Toughpower 850W
ASUS nVidia GTX560 1GB
CoolerMaster HAF 932
CesarePlay
Registered User
Posts: 10628
Joined: 26 Mar 2007, 02:00
Location: In the river of thoughts
Contact:

Re: help with value in asp.net

Post by CesarePlay »

Ok. Here is the code: SAorry for delay. I spotted one mistake:

Here is the the case pointing to the other vb function

Code: Select all

        Select Case Request.Form("txtcheck")
            Case "Check"
                Call safetydata()
        End Select

The second vb code:

Code: Select all

   Private Sub safetydata()
        Dim check As String

        If Request.QueryString("sector") = "S" Then
            Show.Visible = False
            txtaction.text = "S"
        Else
            If Request.QueryString("sector") = "E" Then
                Hide.Visible = False
                txtaction.text = "E"
            End If
        End If
        check = Request.QueryString("sector")

    End Sub
The javascript code:

Code: Select all

			var check
			if (document.Form1.txtcheck.value = "Check"){
			document.Form1.txtAction == check
			check == "safetydata"
			}
			
			window.onload = function()
			{
				if (check == "S"){
				alert(document.getElementById("Hide").tagName);
				
				}
			else {
				if (check == "E"){
				alert(document.getElementById("Show").tagName);
				}
			  }
			}
			alert(check)
			if (check == "E"){  
				if (document.Form1.lstSeverity.selectedIndex == 0 && canSubmit){
						alert("Please select a Severity.")
						document.all.ViewRC1.style.display = "block"
						canSubmit = false
						document.Form1.lstSeverity.focus()
				}
			}
			else {
			if (check == "S"  && canSubmit){
						alert("Please classify the incident.")
						document.all.safety.style.display = "block"
						canSubmit = false
				}
			}
At the moment it seems better but now won't stop saying I have not classified the incident even though I have.
Image
RuadRauFlessa
Registered User
Posts: 20576
Joined: 19 Sep 2003, 02:00
Location: Bloodbank

Re: help with value in asp.net

Post by RuadRauFlessa »

Now that you have posted some code someone with more vb and JavaScript experience than me can give it a shot :D
:rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock:
Spoiler (show)
Intel Core i7-2600k @ 3.4GHz
Corsair Vengence 2x4GB DDR3 2000MHz
Thermaltake Toughpower 850W
ASUS nVidia GTX560 1GB
CoolerMaster HAF 932
CesarePlay
Registered User
Posts: 10628
Joined: 26 Mar 2007, 02:00
Location: In the river of thoughts
Contact:

Re: help with value in asp.net

Post by CesarePlay »

I thought I solved it but still not working
Image
CesarePlay
Registered User
Posts: 10628
Joined: 26 Mar 2007, 02:00
Location: In the river of thoughts
Contact:

Re: help with value in asp.net

Post by CesarePlay »

I solved it. After extensive searching on google I found a solution on page 4.

Here is the solution:


In the page_prerender

Code: Select all

txtcheck.Value = Request.QueryString("sector")
txtcheck was the name of the hidden input box

I declared it as: Protected WithEvents txtcheck As System.Web.UI.HtmlControls.HtmlInputControl

The javascript code is:

Code: Select all

var check = document.getElementById("txtcheck").value;
This gets the value stored in the input field.

Here is the code that validates the checkboxes I needed done earlier yesterday:

Code: Select all

if (check == "E"){  
				if (document.Form1.lstSeverity.selectedIndex == 0 && canSubmit){
						alert("Please select a Severity.")
						document.all.ViewRC1.style.display = "block"
						canSubmit = false
						document.Form1.lstSeverity.focus()
				}
			}
			else {
				if (check == "S" && canSubmit){
					if (!document.Form1.chkCloseCall.checked == true && !document.Form1.chkHPI.checked == true && !document.Form1.chkInjury.checked == true && !document.Form1.chkNonComp.checked == true && !document.Form1.chkPropDamage.checked == true && canSubmit){
						alert("Please classify the incident.")
						document.all.safety.style.display = "block"
						canSubmit = false
						return false
					}
				}
			}
Basically my code was right yesterday but because the value never passed through it did not work but now it works. :D

Edit: html code for it was: <input type="hidden" id="txtcheck" runat="server">
Image
Post Reply