|
Todd Smith wrote:
You need to set the selectedindex property of the dropdownlist.
I've tried, but I'm not sure WHERE or WHEN (in the page lifecycle) that should be set.
Also, I am not clean on how to get the index from the Dataset/DataTable where the values are stored.
Mike Stanbrook
mstanbrook@yahoo.com
|
|
|
|
|
Problem statement: given a document like this:
<?xml version="1.0" encoding="utf-8"?>
<Page xmlns="/PageWriter/TemplateSchema.xsd" xmlns:XHTML="http://www.w3.org/1999/xhtml">
<Head>
<!-- Irrelevant stuff here -->
</Head>
<Body>
<XHTML:p>See, this is how XHTML elements work.</XHTML:p>
<ASP.NET>Response.Write("And this is how ASP.NET is supposed to work!");</ASP.NET>
</Body>
</Page>
called Doc.mhcx (MadHamster Creations XML page format), I want to produce an .aspx file like this:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
<!-- Irrelevant stuff -->
</head>
<body>
<p>See, this is how XHTML elements work.</p>
<% Response.Write("And this is how ASP.NET is supposed to work!"); %>
</body>
</html>
And then serve it up to the client.
Progress so far: I can do everything, except when my <ASP.NET> tags get involved. Then, given a simple <xsl:value-of select="." /> , it will transform all my <s, >s, and &s into their entity equivelants. Needless to say, this is bad.
I got around this with an almost painless hack for JavaScript by this code:
<xsl:text disable-output-escaping="yes"><![CDATA[<% Response.Write(PageWriter.UnescapeText(@"]]></xsl:text>
<xsl:value-of select="translate(., '"', '░')" />
<xsl:text disable-output-escaping="yes"><![CDATA[")); %>]]></xsl:text>
Where the current context (. ) is the JavaScript code and PageWriter.UnescapeText is a ASP.NET function that will fix all the <s, >s, and &s that XSL mangled. There's also an added complication that because this is going to be a string paramter, I use XSL to turn all "s into ░s (░s, if the browser will display this) on the assumption that nobody will ever use that character in JS code, and then PageWriter.UnescapeText turns those weird characters back into "s. This is to avoid making every " in the JS end the parameter to PageWriter.UnescapeText . Ugly, but it works.
But this obviously doesn't work for ASP.NET, because I can't pass ASP.NET code to an ASP.NET function (unless there's some JS eval type function I'm not aware of somewhere?) So...
Current idea for a hack, the implementation of which is not working right now:
If the .mhcx document has <ASP.NET> tags (inputDoc.GetElementsByTagName("ASP.NET").Count > 0 ), then do special things, like:
create a temporary .mhcx file with all <s, >s, and &s replaced by far-out Unicode characters that nobody will ever use. Then do normal transformation of .mhcx to .aspx. Of course, at this point we've still got weird Unicode chars, so read in the .aspx file, turn the chars back into <s, >s, and &s, then write out the .aspx file again.
Finally, display this .aspx file to the client.
Notes: This is really rather repulsive.
The best solution would be to make XSL somehow spit out <s, >s, and &s unmolested. That fixes everything, really. No need for any special cases, even for JavaScript code.
Another not-so-great solution would be to have my output format for XSL be text instead of XML. Then it won't mangle things, but... that's just wrong, y'know?
I guess I could also give up XSL entirely and just use ASP.NET processing... unhappy, but painless.
Otherwise, I'm kind of at a loss.
Please note that speed won't be an issue. Although all this processing is currently done on every request, in the future I'll just have a .exe that will scan all .mhcx files on my local server and turn them into .aspxs. Then, assuming this .exe is run after any changes to .mhcx files, all the .mhcx handler will have to do is lookup the URL for the corresponding .aspx, which is quite simple and speedy.
Help?
-Domenic Denicola- [CPUA 0x1337]
MadHamster Creations
"I was born human. But this was an accident of fate - a condition merely of time and place. I believe it's something we have the power to change..."
|
|
|
|
|
Well, I've it working. Now it's simply a matter of this is not pretty, I hate it! instead of This is not pretty and it doesn't work and I'm tired of staring at exceptions.
I migrated my server-sided solution for ASP.NET code to JavaScript also. So basically, whenever a file has <JavaScript> or <ASP.NET> tags, all <s, >s, and &s inside of those tags will be transformed into high-up Unicode characters. Then this new document will be XSL'ed into a .aspx file, and finally I will turn the Unicode characters back into <s, >s, and &s. The end result is then shot to the client.
If a file doesn't have those tags, it will be XSL'ed like normal.
-Domenic Denicola- [CPUA 0x1337]
MadHamster Creations
"I was born human. But this was an accident of fate - a condition merely of time and place. I believe it's something we have the power to change..."
|
|
|
|
|
i have a combo-box which displays a list of skills. however, if i wish to add another skill, i also have an option in the combo-box "Add a Skill". how do i redirect the user to the "add" page if they choose this option? (if they choose any other option, it goes to a different page).Here's my (very incorrect!)code:
<SELECT NAME="Skills">
<%
Do While Not RS.EOF
Response.Write "<OPTION VALUE='" & RS("Skill") & "'>"
Response.Write RS("Skill")
RS.MoveNext
Loop
%><option value="add">Add a Skill</option><%
RS.Close
objConn.Close
Set RS = Nothing
Set objConn = Nothing
%>
</SELECT>
<P>
<INPUT TYPE="submit" name="btnAdd" value="Register">
<INPUT TYPE="submit" name="btnAdd" value="Add">
<%
If (Request("btnAdd") = "Add") AND (Request("Skills") = "Add a Skill") Then
Response.Redirect("add2.asp")
end if
%>
....further code....
thank you!
|
|
|
|
|
mcm wrote:
Here's my (very incorrect!)code:
You are going to kick yourself
Your if statement is checking for the TEXT attribute of the selected drop down item, not the VALUE attribute.
So just change this line If (Request("btnAdd") = "Add") AND (Request("Skills") = "Add a Skill") Then to If (Request("btnAdd") = "Add") AND (Request("Skills") = "add") Then and voila, should work (works on mine.)
So otherwise your code is fine.
regards,
Paul Watson
Bluegrass
Cape Town, South Africa
Simon Walton wrote:
"You come across a lot of people who call themselves realists, when they are actually pessimists attempting to look intelligent."
|
|
|
|
|
thank you so much for your help! im afraid i tried that and it didnt work - it seems to be ignoring the if statement completely - it always directs itself to the register.asp page.
|
|
|
|
|
mcm wrote:
thank you so much for your help! im afraid i tried that and it didnt work - it seems to be ignoring the if statement completely - it always directs itself to the register.asp page.
Hmm odd. Could you email me the output (the actual HTML produced after having run your ASP script) and the ASP file itself?
I noticed you are not closing your OPTION elements which could be a problem and also the actual values from your recordset may be interefering with the select element.
regards,
Paul Watson
Bluegrass
Cape Town, South Africa
Simon Walton wrote:
"You come across a lot of people who call themselves realists, when they are actually pessimists attempting to look intelligent."
|
|
|
|
|
Does anyone have a simple example of how I can implement collapsable tables? (like the way the forum posts work here in DHTML mode)
Basically I want to be able to put a link at the top of a table that when clicked will collapse away the table so that only the header is visable (clicking on the link again would re-expand the table).
Being able to specify (in the html) whether a table starts open or closed would be a bonus too, but I'm not worried about things like making sure only one table is visable (I just want to be able to let users hide away unneeded information)
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|
benjymous wrote:
Basically I want to be able to put a link at the top of a table that when clicked will collapse away the table so that only the header is visable (clicking on the link again would re-expand the table).
Quite simple once you figure it out. All you need to do is set the style.display attribute of an element to none to hide it, and block to display it. You can use JavaScript to do this client-side.
You can default it to hidden by using a style="display: none" attribute on the elements.
Here is a very simple example and can be easily expanded for a dynamic page by replacing the element IDs with a variable.
<table>
<tr>
<td style="cursor: hand; background-color: #cccccc;" onclick="javascript:if (document.all.descrip1.style.display == 'none'){document.all.descrip1.style.display = 'block'}else{document.all.descrip1.style.display = 'none'}">Title 1</td>
</tr>
<tr id="descrip1">
<td>Description</td>
</tr>
<tr>
<td style="cursor: hand; background-color: #cccccc;" onclick="javascript:if (document.all.descrip2.style.display == 'none'){document.all.descrip2.style.display = 'block'}else{document.all.descrip2.style.display = 'none'}">Title 2</td>
</tr>
<tr id="descrip2">
<td>Description</td>
</tr>
</table>
regards,
Paul Watson
Bluegrass
Cape Town, South Africa
Simon Walton wrote:
"You come across a lot of people who call themselves realists, when they are actually pessimists attempting to look intelligent."
|
|
|
|
|
Brilliant!
Lets see if I can get this working with my site
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|
more details please - test message for forum
|
|
|
|
|
|
Interesting...is this supported NS6+ also...? Or would you have to use visibility property for that...?
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Hockey wrote:
Interesting...is this supported NS6+ also...? Or would you have to use visibility property for
First off you cannot use (as far as I know) the document.all method of getting the element in Netscape 6+ (Mozilla.) Instead one needs to use the getElementById method, which IE supports as well (I should have used that method rather than document.all but I was feeling lazy .)
display is as far as I know the preferred way of hiding and displaying elements when you want the document to reflow on change. If you use visibility then the document should not reflow as effectively the element is still "there", just not visible. So if you want to hide an element but not have the other elements reflow to fill up the empty space then use visibility . If you want other elements to reflow though, then use display .
For display you have three possible values. block , inline and none . They do pretty much what they say. e.g. By default a span element has a display of inline meaning it will not cause line breaks and will generally flow with the text. By default div elements though have a display of block meaning it will cause line breaks and not flow with the text. You could if you want set the div display attribute to inline and override that default behavouir, making the div flow with the text. This is useful for form elements where you don't want the form to cause any line breaks.
And yes display is supported in NS6+ (Mozilla.) It is part of the W3C CSS standard.
This concludes Paul on CSS 101 Chapter 6...
regards,
Paul Watson
Bluegrass
Cape Town, South Africa
Simon Walton wrote:
"You come across a lot of people who call themselves realists, when they are actually pessimists attempting to look intelligent."
|
|
|
|
|
Hi,
Does anyone know how to configure IIS 5 so that mail sent using CDONTS does not go to the Badmail queue? I eventually figured out where it was going, but am unsure what to do about it
Thanks
Polymorph
|
|
|
|
|
Megan Forbes wrote:
CDONTS does not go to the Badmail queue
There is a reason it is going there. If your using SMTP to send the mail, is it configured correctly in the code or applicaiton using CDONTS ??
Soliant | email
"the result is that VC7 is the only compiler to generate optimized MSIL" - Stanley Lippman
|
|
|
|
|
Can somebody please explain to me why the following html shows only 2 children? This is the code that .NET spits out for a RadioButtonList. I'm testing this on Netscape 6.2 (browser compatibility tests).
<table id="RadioButtonList1" border="0">
<tr>
<td><input id="RadioButtonList1_0" type="radio" name="RadioButtonList1" value="Item 1" checked="checked" /><label for="RadioButtonList1_0">Item 1</label></td>
</tr><tr>
<td><input id="RadioButtonList1_1" type="radio" name="RadioButtonList1" value="Item 2" /><label for="RadioButtonList1_1">Item 2</label></td>
</tr><tr>
<td><input id="RadioButtonList1_2" type="radio" name="RadioButtonList1" value="Item 3" /><label for="RadioButtonList1_2">Item 3</label></td>
</tr><tr>
<td><input id="RadioButtonList1_3" type="radio" name="RadioButtonList1" value="Item 4" /><label for="RadioButtonList1_3">Item 4</label></td>
</tr>
</table>
Here's the Javascript that's reporting 2 children:
var ctrl=document.getElementById("RadioButtonList1");
if (!ctrl.type && typeof(ctrl.firstChild)!='undefined')
{
alert(ctrl.childNodes.length);
}
Huh? Any ideas?
Thanks in advance.
Jamie Nordmeyer
Portland, Oregon, USA
|
|
|
|
|
You're probably picking up a THEAD and a TBODY, which get thrown in just to confuse you!
This should help you find out what the structure is:
NB: I've only tested this on IE6, but it should work!
<html>
<head>
<title>Test Child Nodes</title>
<script language="javascript">
<!--
function Test() {
var lst = document.getElementById("lstControls");
var ctrl = document.getElementById("RadioButtonList1");
if (!ctrl.type && typeof(ctrl.firstChild)!='undefined') {
IterateControl(ctrl, '', lst);
}
}
function IterateControl(oParent, sParent, lst) {
for(var i=0; i<oParent.childNodes.length; i++) {
var item = oParent.childNodes[i];
if (item.tagName) {
var opt = document.createElement("OPTION");
opt.text = sParent + item.tagName;
opt.value = item.outerHTML;
lst.add(opt);
IterateControl(item, sParent + ' ', lst);
}
}
}
function showControl(lst) {
var lbl = document.getElementById("lblControl");
lbl.innerText = lst.options[lst.selectedIndex].value;
}
</script>
</head>
<body>
<table id="RadioButtonList1" border="0">
<tr>
<td>
<input id="RadioButtonList1_0" type="radio" name="RadioButtonList1" value="Item 1" checked="checked" />
<label for="RadioButtonList1_0">Item 1</label>
</td>
</tr>
<tr>
<td>
<input id="RadioButtonList1_1" type="radio" name="RadioButtonList1" value="Item 2" />
<label for="RadioButtonList1_1">Item 2</label>
</td>
</tr>
<tr>
<td>
<input id="RadioButtonList1_2" type="radio" name="RadioButtonList1" value="Item 3" />
<label for="RadioButtonList1_2">Item 3</label>
</td>
</tr>
<tr>
<td>
<input id="RadioButtonList1_3" type="radio" name="RadioButtonList1" value="Item 4" />
<label for="RadioButtonList1_3">Item 4</label>
</td>
</tr>
</table>
<button onclick="Test();">Test</button>
<br />
<select size="20" id="lstControls" onchange="showControl(this);">
</select>
<br />
<div id="lblControl" style="font-family:Courier New; font-size:10pt; color:navy;"></div>
</body>
</html>
|
|
|
|
|
The whole error message is as follows. BTSWebService is the name of my project
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Could not load type 'BTSWebService.Global'.
Source Error:
Line 1:
what should be the solution???
please help me out.
|
|
|
|
|
Is it possible to create a page template that contains a server-side <form> element? I would like to create a template that contains a few server-side controls.
I've played around with creating a template with a <form>, but it seems the only <form> element I can create on the template is an HTMLForm.
When I run a page that inherits from this template, the page has no VIEWSTATE, and cannot do postbacks. If the <form> is on the page instead of on the template, the page does have VIEWSTATE and postbacks work correctly.
|
|
|
|
|
Has anyone used the RichTextBox ASP.NET control in a project yet?
So far it looks very good and exactly what we need for our CMS, but I do not want to get my hopes up all over again and then have them dashed
Any opinions appreciated, ta.
regards,
Paul Watson
Bluegrass
Cape Town, South Africa
Simon Walton wrote:
"You come across a lot of people who call themselves realists, when they are actually pessimists attempting to look intelligent."
|
|
|
|
|
I haven't used it, but it's easy enough (and cheaper ) to roll your own.
I've got a version wrapped up as an HTML behaviour and a few supporting pages. It doesn't have the design-time support and toolbar customization, but the basics are there:
http://www.trinet.co.uk/trinet/feedback.asp[^]
|
|
|
|
|
Richard_D wrote:
but it's easy enough (and cheaper ) to roll your own.
Yeah we tried to roll our own for a project once (I had three days in which to do it though which bites.)
The basics are all pretty easy to do using IE. It is when you get to more complex features, such as applying CSS classes, that things start to unravel (and which the RichTextBox seems to do well.)
Also we need to output XHTML compliant code, though I recently figured out I can pipe-line HTML Tidy into the solution to get this done.
There were lots of niggly issues we ran into when doing our own, which RichTextBox seems to get around.
Richard_D wrote:
http://www.trinet.co.uk/trinet/feedback.asp[^]
Looks great. How can we make use of it in a commercial project? (not for re-sell but a bespoke CMS system for our clients)
i.e. What are your licensing terms?
regards,
Paul Watson
Bluegrass
Cape Town, South Africa
Simon Walton wrote:
"You come across a lot of people who call themselves realists, when they are actually pessimists attempting to look intelligent."
|
|
|
|
|
Paul Watson wrote:
Also we need to output XHTML compliant code,
I can't guarantee that it would be 100% XHTML compliant, but it does have a good go. The tags and attribute names will be in lower case, attribute values will be quoted, all tags will be closed, and all tags will be properly nested.
Paul Watson wrote:
What are your licensing terms?
$80 (US), or £57 (GBP), including source code.
The current properties are below. I keep "playing" with it, so it might get more features!
Properties:
- formname
- Name of the form element
- width
- Css width for this element
- height
- Css height for this element
- value
- HTML content. If not specified, the value is taken either from the element specified in formname (if it exists), or the innerHTML of the element.
- usebr
- True to use <br /> on Enter. False (or not specified) to use <p>
- cssurl
- Full Url to the Css file to use
- includeSource
- Allow access to HTML source?
- includeSpelling
- Allow user to run spell-checker?
- includeTable
- Allow user to insert tables?
- includeSymbol
- Show a drop-down list of symbols
- includeCurrSymbol
- Include currency symbols
- includeTMSymbol
- Include TM, (c), etc
- includeFmtSymbol
- Include formatting symbols
- includeAccentSymbol
- Include accents
- includeMathSymbol
- Include mathematical symbols
- includeArrowSymbol
- Include arrows
- limit
- Maximum number of characters to allow (0 or not specified = unlimited
- imgdir
- Image folder for toolbars
- basepath
- Base Url for images - use blank for current
Standard Inserts:
If includeSymbol = true, standard inserts can be added by including the following within the element:
<div class='HTML_INSERT' style='display:none;' text='[CAPTION OF INSERT]'<
[HTML to insert]
</div>
Client Side Events:
All events have the following properties:
- srcElement
- This element
- srcHTML
- The HTML editor
- returnValue
- Set to false to prevent processing
Events:
onbeforeparastyle
Fires before applying a paragraph style
- newStyle
- The style to be applied
onbeforefontsize
Fires before changing the font size
- newSize
- The new size
onbeforefontname
Fires before changing the font name
- newFont
- The new font
oninserttable
Fires before inserting a table
- tableAttributes
- Attributes for the table
- showDialog
- Return false to insert without prompting
onsetcolor
Fires before setting the foreground or background colour
- mode
- BG or FG
- newColor
- Return a colour
- showDialog
- Return false to set the colour without prompting
- dialogUrl
- Url of the colour dialog
- dialogAttributes
- Attributes for the colour dialog
oncheckspelling
Fires before the spell-checker window is opened
- dialogUrl
- Url to the spell-checker
- dialogWidth
- Width of the window
- dialogHeight
- Height of the window
oninsertimage
Fires before inserting an image
- showWarning
- Return false to prevent the warning message
- showDialog
- Return false to prevent the Url prompt
- imageUrl
- Url of the image
oninsertlink
Fires before inserting a hyperlink
- showDialog
- Return false to prevent the Url prompt
- Url
- Url for the link
oninsertsymbol
Fires before inserting a symbol
- symbol
- Symbol to insert
Example
<html>
<head>
<title>Test</title>
<link rel="stylesheet" href="htmleditor_ctrl_xp.css" />
<script language="javascript">
<!--
function test() {
alert(document.getElementById("test").value);
}
function testLink() {
event.showDialog = false;
event.Url = "http://www.codeproject.com/";
}
</script>
</head>
<body>
<div
style="width:100%; behavior:url(htmleditor.htc);"
id="testHTML" formname="test"
includeSymbol="1"
includeAccentSymbol="0" includeArrowSymbol="0"
includeMathSymbol="0" includeFmtSymbol="0"
usebr="1" oninsertlink="testLink()"
>
<!--The form element. The editor will take it's value from this.-->
<textarea name="test" id="test" rows="5" cols="50">
<p><em>Test</em> of HTML HTC</p>
</textarea>
<!--The easiest way to check whether the editor was run from the server:-->
<input type="hidden" name="test_IsHTML" value="0" />
<!--A custom insert.-->
<div class="HTML_Insert" style="display:none;" text="Disclaimer">
<hr size="1" color="#eeeeee" noshade />
<span>Well, this works then!</span>
</div>
</div>
<button onclick="test();">Test</button>
</body>
</html>
IE5+ users will get the editor, everyone else will get the standard text-box.
|
|
|
|
|
Alternatively, if that's too much, this[^] article might be of interest.
|
|
|
|
|