473,785 Members | 2,458 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Global variable lost in Change event Handler?

BACKGROUND
----------
I have an ASP.NET application having two panels. In one panel, an XML
document, transformed using xsl, is displayed. In the other panel are some
controls that allow a user to change the xml. For example, each "l_item"
element appears as a row in a table labelled with a "label"; so if I have

<l_item id="1">
<label>blah</label>
...
</l_item>

it appears on the web page as

-------------
BLAH:
...
-------------

In the other panel there is a textbox control, where the user can type a new
label and click a button, causing the xml document to change and thus the
display to change.

If a "l_item" has been changed from the original xml, I want the attribute
for that item to change. Using the above example if the user changed the
label to "blahblah" I want the xml to look like this:

<l_item id="-1">
<label>blahblah </label>
...
</l_item>

(When the user is finished, the document is sent to a database procedure
that only bothers to update records where the id is a negative number.)

CODING
------
Without going into too much detail, I have methods that change the xml
document in response to the control values and a XmlNodeChangedE ventHandler
that changes the "l_item".

...//global variables
Protected selected As String
Protected selectednode As XmlNode
...

(In Page_Load)
...
A selected = Request.Form("s electedrow")
B selectednode =
xmlegend.Docume ntElement.Selec tSingleNode("//l_item/label='" & selected &
"']")
...

(In the label text box method)
...
C If selectednode Is Nothing Then Exit Sub
Try
D selectednode.It em("label").Inn erText = label_txt.Text
Catch ex As Exception
E emessage = ex.Message
...

(In the node change handler)
If (args.Action = XmlNodeChangedA ction.Change And args.Node.Local Name
<> "id") Then
F coi = selectednode.At tributes.Item(0 ).InnerText
If Not (coi.StartsWith ("-")) Then
selectednode.At tributes.Item(0 ).InnerText = "-" & coi
End If
End If

PROBLEM
-------
Line F throws a "Object reference not set to an instance of an object"
exception. When debugging using VS, the debugger shows that when the page
reloads after changing the label text box, "selected" is set to the correct
value at line A and that "selectedno de" becomes a valid XMLElement at line B.
At lines C and D, the debugger shows these values are still there. Flow
branches to the node change handler, coming to line F as it should. But the
debugger shows that at line F both "selected" and "selectedno de" are
"Nothing". Flow goes back to the exception handler, line E, which shows
"selected" and "selectedno de" are the same legitimate values they were before.
So somehow, the node change handler doesn't see the global variable values.
How can I get this to work?

Many thanks.
Nov 12 '05 #1
0 1830

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
5856
by: Fred Basset | last post by:
I am modifying existing code to add modal functionality to an IE5+ ActiveX Web-App. What I am trying to achieve is simple modal behaviour on popup windows, apart from certain specified ones. I initially attempted to use a direct assignment to the onblur handler of the new window, but for some reason couldn't get it to work, so I've instead used attachEvent. This provides simple modal functionality. The problem that I need help with is...
1
2186
by: Sandman | last post by:
Below you find a small test page. I contains an input box, with an onBlur event, and a form, with an onSubmit event. When I place the cursor in the text box and push ENTER, first the onBlur event and then the onSubmit event is raised. The onBlur event displays the value of the global variable , it changes the value of the global variable to and displays it again . The onSubmit event simply displays the value of the global variable
3
3039
by: tafs7 | last post by:
My code below is supposed to email me when an error occurs on the application, but it's not emailing anything. Am I missing something? I know the smtp servers I've tried work. I even added a App_Start handler to see if I could get emailed at all even from the first request of the app, but to no avail. Could someone please help me out? Thanks a lot! --Thiago Web developer AgniTEK
2
4734
by: Bela | last post by:
Hello I was wondering if someone could help me out with a Session_End problem in my Global.asax. I've tried everything, and still no success Here is the scenario: sessionstate is set to InProc. I have timeout set to 1 min I have a variable in session_start that is incremented each new session, and it is then decremented in Session_End. I use this variable on a web form to show current users online. All of this works just fine, so I...
4
6362
by: Marc Missire | last post by:
Hi, I have an issue below I'd love help with, involving a static variable, Application_Start, and a background thread. In global.asax.cs I have a static variable (outside any method) with a default value, such as: private static string serverName = string.Empty;
3
3749
by: kingski | last post by:
I have a web site created with ASP.NET 1.1. availability Global.asax: protected void Application_PreRequestHandlerExecute(Object sender, EventArgs e)
5
2865
by: aamirghanchi | last post by:
Hi, I need to know if anyone else came across this. The Session variable value I set in a sortCommand event handler of a datagrid does not hold on till the next sortcommand event handler and reverts back to its original value, the one I had set it before in the previous trip sortcommand event handler. I am trying to implement bidirectional sorting on a datagrid by making use of session variable Session("SDirection"). In the sortcommand...
3
2891
by: thomson | last post by:
Hi All, i do have an website with the URL http://localhost/application/ASEAN-ANZ, Once i hit the application, it goes to the Global.asax. but after that if i tried to change the URL http://localhost/application/en-US, the global.asax is not fired.
20
12761
by: teddysnips | last post by:
Weird. I have taken over responsibility for a legacy application, Access 2k3, split FE/BE. The client has reported a problem and I'm investigating. I didn't write the application. The AutoExec macro calls a function "InitApplication" which, in turn, calls a function to set the value of a global string variable
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10091
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8972
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6739
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.