Friday, March 16, 2012
populating a list box by alphabetical surname
I have a listbox contianing strings which ahs been populated from a databsae via "SELECT * FROM researchers"
i.e
John Doe www.johndoe.com
David Allen www.daveallen.com
Andrew Rodgers www.andrewdavidson.com
..
I need this to be displayed as
David Allen www.daveallen.com
John Doe www.johndoe.com
Andrew Rodgers www.andrewdavidson.com
i.e alphabetically by surname?
How do I do this?SELECT * FROM researchers ORDER BY LastName ASC
Populating a Stream object with XML and then convert Stream into a String Options
I am trying to populate a Stream via an XML Serializer and then
convert that stream of xml into a string.
I have been able to successfully serialize an object into a physical
xml file written to my local disk. The XML file has content and looks
as I would expect, here is the code for that action:
TextWriter writer = new StreamWriter(@dotnet.itags.org."c:\test.xml");
serializer.Serialize(writer, oData);
When I try to to serialize my object to a stream of xml and then
convert to a string I get no content in the string. Both the
MemoryStream and StreamWriter object appear to have the correct byte
size after I populate them with the serialized data. Is there an
alternative way I should be doing this? Here is the code I'm using:
MemoryStream ms = new MemoryStream();
StreamWriter sw = new StreamWriter(ms);serializer.Serialize(sw, oData);
StreamReader sr = new StreamReader(ms);
string test = "";
test = sr.ReadToEnd(); //No content is populated, why?
Thank you,
Darren
dstahl:
MemoryStream ms = new MemoryStream();
StreamWriter sw = new StreamWriter(ms);serializer.Serialize(sw, oData);
StreamReader sr = new StreamReader(ms);
string test = "";
test = sr.ReadToEnd(); //No content is populated, why?Thank you,
Darren
Hi Darren,
In your code, after you serialize your sw, you couldn't new it again, because that will create sw again.
Try to cancel that line : "StreamReader sr = new StreamReader(ms); ". As you know, if you do like your way, ms has nothing, then sw has nothing too, even if you have initialize the sw before.
Hope this helps. Thanks.
Populating DIV tag from javascript via ASP.Net & ClientScript methods
ASP.Net pages. I am using the ClientScript.RegisterClient...() methods
to register an external javascript file within ASP.Net. When I put my
code on a ASP button and click it it works just find, runs my
javascript which popus up an alert and then changes the div text.
However, when I put this on a Page_Load event the alert comes up ok but
the changing of the div text does not occur. I have a feeling this has
something to do with not all the page elements being rendered or
avaiable in some way to the javascript. I've tried placing the code in
LoadComplete, and Init, with the same results. Any suggestions on how I
can get my javascript code to be triggered on page load from ASP and be
able to access page elements like div tags? I don't have my code in
front of me now but could come up with example if needed. Any advice is
appreciated.
David Mathew
mathewda@dotnet.itags.org.gmail.comusing masterpages? if so, it changes the client ID
Dave Mathew wrote:
Quote:
Originally Posted by
I'm trying to run some clientside javascript on page load for one of my
ASP.Net pages. I am using the ClientScript.RegisterClient...() methods
to register an external javascript file within ASP.Net. When I put my
code on a ASP button and click it it works just find, runs my
javascript which popus up an alert and then changes the div text.
However, when I put this on a Page_Load event the alert comes up ok but
the changing of the div text does not occur. I have a feeling this has
something to do with not all the page elements being rendered or
avaiable in some way to the javascript. I've tried placing the code in
LoadComplete, and Init, with the same results. Any suggestions on how I
can get my javascript code to be triggered on page load from ASP and be
able to access page elements like div tags? I don't have my code in
front of me now but could come up with example if needed. Any advice is
appreciated.
>
David Mathew
mathewda@.gmail.com
I think what you are running into is the javascript code being executed
before the elements of your page have been created in the page DOM.
Try to stick your javascript into the onload attribute of your body tag
and see if it will work.
If this does work, I think what you will have to do is register your
javascript with the onload event either by adding it as an attribute of
the body tag or via external script.
http://www.quirksmode.org/js/events_advanced.html
The above article is similar to what you could use to register your
javascript with the load event except of course the event you want to
register for is load (onload in IE) and I believe you want to use
window as your element.
I wrote a javascript register function that handles cross browser
registration a while ago but don't have it with me. Let me know if you
want it and I'll post it. I believe there are also similar examples
out there somewhere on the web.
Clint.
Dave Mathew wrote:
Quote:
Originally Posted by
I'm trying to run some clientside javascript on page load for one of my
ASP.Net pages. I am using the ClientScript.RegisterClient...() methods
to register an external javascript file within ASP.Net. When I put my
code on a ASP button and click it it works just find, runs my
javascript which popus up an alert and then changes the div text.
However, when I put this on a Page_Load event the alert comes up ok but
the changing of the div text does not occur. I have a feeling this has
something to do with not all the page elements being rendered or
avaiable in some way to the javascript. I've tried placing the code in
LoadComplete, and Init, with the same results. Any suggestions on how I
can get my javascript code to be triggered on page load from ASP and be
able to access page elements like div tags? I don't have my code in
front of me now but could come up with example if needed. Any advice is
appreciated.
>
David Mathew
mathewda@.gmail.com