Re: #include for a DropDownList?
- From: "Beemer Biker" <jstateson@xxxxxxxx>
- Date: Tue, 23 Jan 2007 09:30:07 -0600
THANKS THANKS THANKS!
"Steven Cheng[MSFT]" <stcheng@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:tDmN6JiPHHA.2488@xxxxxxxxxxxxxxxxxxxxxxxxx
Thanks for your reply Joseph,
For your two questions:
1) Occassionally I have a list of delimited strings and would
like to get them into a C# page. This is usually for testing purposes as
I
need a quick source of data to test out some code. However, I can just as
well copy and paste it into the code.
========================================
If just for test purpose, another option would be define a utility class
which use some public methods(static or non-static) to return some list of
data items. And for any test page want to use those data, you can simply
drag a ObjectDataSource on the page and use ObjectDataSource to reference
that utility class. And those databound control like DropdownList,
GridView
... can directly use that objectdatasource to populate test data. How do
you think?
This worked fine. I had no idea that once I defined that ConstantUtil
class, it would show up as a DataSource. The first time I ever looked at an
ObjectDataSource its properties had an empty list for sources. I didnt know
that defining a class would populate that list.
2) For the global server url question, I think you can use a similar way
which can synchronize the value better. Define a public utility class
which
use static variables to hold the const url string. And in page template,
you can use server-side expression to render out the static const variable
to client script fragement. e.g.
=======util class=======
namespace TestNS
{
public class ConstantUtil
{
public
}
I had to put "static public string ServiceUrl" or the jscript below would
give an error. Leaving off static the C# still worked, but not the jscript.
Thanks again, I learned quite a byte today!
........
}
===============
=====aspx template========
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript">
var url = '<%= TestNS.ConstantUtil.ServiceUrl %>';
</script>
.......
.
- References:
- RE: #include for a DropDownList?
- From: Steven Cheng[MSFT]
- Re: #include for a DropDownList?
- From: Beemer Biker
- Re: #include for a DropDownList?
- From: Steven Cheng[MSFT]
- Re: #include for a DropDownList?
- From: Beemer Biker
- Re: #include for a DropDownList?
- From: Steven Cheng[MSFT]
- RE: #include for a DropDownList?
- Prev by Date: Re: DetailsView Default Mode
- Next by Date: Re: How to know the selected row in a DataControlField
- Previous by thread: Re: #include for a DropDownList?
- Next by thread: Dropdown Selection Changed Problem in Repeater Control during Postback of page
- Index(es):
Relevant Pages
|