help with value in asp.net
-
- Registered User
- Posts: 10628
- Joined: 26 Mar 2007, 02:00
- Location: In the river of thoughts
- Contact:
help with value in asp.net
I need a value in asp.net to be ready in javascript. Can anyone help with this? I use vb.net 2003.
- 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
Your question is too vague to receive a useful answer; please define it better.
Kia kaha, Kia māia, Kia manawanui.
-
- Registered User
- Posts: 10628
- Joined: 26 Mar 2007, 02:00
- Location: In the river of thoughts
- Contact:
Re: help with value in asp.net
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.
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.
-
- Registered User
- Posts: 20576
- Joined: 19 Sep 2003, 02:00
- Location: Bloodbank
-
- Registered User
- Posts: 10628
- Joined: 26 Mar 2007, 02:00
- Location: In the river of thoughts
- Contact:
Re: help with value in asp.net
Ok. Here is the code: SAorry for delay. I spotted one mistake:
Here is the the case pointing to the other vb function
The second vb code:
The javascript code:
At the moment it seems better but now won't stop saying I have not classified the incident even though I have.
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
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
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
}
}
-
- Registered User
- Posts: 20576
- Joined: 19 Sep 2003, 02:00
- Location: Bloodbank
Re: help with value in asp.net
Now that you have posted some code someone with more vb and JavaScript experience than me can give it a shot
- Spoiler (show)
-
- Registered User
- Posts: 10628
- Joined: 26 Mar 2007, 02:00
- Location: In the river of thoughts
- Contact:
Re: help with value in asp.net
I thought I solved it but still not working
-
- Registered User
- Posts: 10628
- Joined: 26 Mar 2007, 02:00
- Location: In the river of thoughts
- Contact:
Re: help with value in asp.net
I solved it. After extensive searching on google I found a solution on page 4.
Here is the solution:
In the page_prerender
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:
This gets the value stored in the input field.
Here is the code that validates the checkboxes I needed done earlier yesterday:
Basically my code was right yesterday but because the value never passed through it did not work but now it works.
Edit: html code for it was: <input type="hidden" id="txtcheck" runat="server">
Here is the solution:
In the page_prerender
Code: Select all
txtcheck.Value = Request.QueryString("sector")
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;
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
}
}
}
Edit: html code for it was: <input type="hidden" id="txtcheck" runat="server">