Showing posts with label aspx. Show all posts
Showing posts with label aspx. Show all posts

Thursday, March 29, 2012

Populate 2nd dropdown list based on selecteditem in first with out postback?

Hi All:

I have an aspx page that has 2 dropdownlists. I want to populate the second
dropdownlist based on the selecteditem in the first dropdown. I know I can
do this by doing a post back and using the selectedindex and loading the
second dropdownlist.

Is there anyway I can do this without doing a postback? Any ideas/pointers
will be much appreciated.

Thanks!

VinayYou'll have to use JavaScript in the client.

search: dependent listbox

<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/

"Vinay" <vinay_hs_removethis@.nospam.yahoo.com> wrote in message
news:ef$cOw4oFHA.2976@.TK2MSFTNGP12.phx.gbl...
> Hi All:
> I have an aspx page that has 2 dropdownlists. I want to populate the
> second dropdownlist based on the selecteditem in the first dropdown. I
> know I can do this by doing a post back and using the selectedindex and
> loading the second dropdownlist.
> Is there anyway I can do this without doing a postback? Any ideas/pointers
> will be much appreciated.
> Thanks!
> Vinay
Thanks for the pointer - will do some reading and see if I can implement it.

"clintonG" <csgallagher@.REMOVETHISTEXTmetromilwaukee.com> wrote in message
news:ek$zp%234oFHA.3656@.TK2MSFTNGP09.phx.gbl...
> You'll have to use JavaScript in the client.
> search: dependent listbox
> <%= Clinton Gallagher
> METROmilwaukee (sm) "A Regional Information Service"
> NET csgallagher AT metromilwaukee.com
> URL http://metromilwaukee.com/
> URL http://clintongallagher.metromilwaukee.com/
>
> "Vinay" <vinay_hs_removethis@.nospam.yahoo.com> wrote in message
> news:ef$cOw4oFHA.2976@.TK2MSFTNGP12.phx.gbl...
>> Hi All:
>>
>> I have an aspx page that has 2 dropdownlists. I want to populate the
>> second dropdownlist based on the selecteditem in the first dropdown. I
>> know I can do this by doing a post back and using the selectedindex and
>> loading the second dropdownlist.
>>
>> Is there anyway I can do this without doing a postback? Any
>> ideas/pointers will be much appreciated.
>>
>> Thanks!
>>
>> Vinay
>>

Populate 2nd dropdown list based on selecteditem in first with out postback?

Hi All:
I have an aspx page that has 2 dropdownlists. I want to populate the second
dropdownlist based on the selecteditem in the first dropdown. I know I can
do this by doing a post back and using the selectedindex and loading the
second dropdownlist.
Is there anyway I can do this without doing a postback? Any ideas/pointers
will be much appreciated.
Thanks!
VinayYou'll have to use JavaScript in the client.
search: dependent listbox
<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/
"Vinay" <vinay_hs_removethis@.nospam.yahoo.com> wrote in message
news:ef$cOw4oFHA.2976@.TK2MSFTNGP12.phx.gbl...
> Hi All:
> I have an aspx page that has 2 dropdownlists. I want to populate the
> second dropdownlist based on the selecteditem in the first dropdown. I
> know I can do this by doing a post back and using the selectedindex and
> loading the second dropdownlist.
> Is there anyway I can do this without doing a postback? Any ideas/pointers
> will be much appreciated.
> Thanks!
> Vinay
>
Thanks for the pointer - will do some reading and see if I can implement it.
"clintonG" < csgallagher@.REMOVETHISTEXTmetromilwaukee
.com> wrote in message
news:ek$zp%234oFHA.3656@.TK2MSFTNGP09.phx.gbl...
> You'll have to use JavaScript in the client.
> search: dependent listbox
> <%= Clinton Gallagher
> METROmilwaukee (sm) "A Regional Information Service"
> NET csgallagher AT metromilwaukee.com
> URL http://metromilwaukee.com/
> URL http://clintongallagher.metromilwaukee.com/
>
> "Vinay" <vinay_hs_removethis@.nospam.yahoo.com> wrote in message
> news:ef$cOw4oFHA.2976@.TK2MSFTNGP12.phx.gbl...
>

Wednesday, March 21, 2012

Populate TextBox With DB Records

This function in a VB class file takes UserID as a parameter & returns
a SqlDataReader to the calling function which exists in a ASPX page:
Namespace NConnect
Public Class Cart
Private sqlConn As New SqlConnection("....")
Public Function GetAddress(ByVal UserID As Integer) As
SqlDataReader
Dim sqlCmd As SqlCommand
Dim sqlReader As SqlDataReader
sqlCmd = New SqlCommand("NETGetAddress", sqlConn)
sqlCmd.CommandType = CommandType.StoredProcedure
Try
With sqlCmd
.Parameters.Add("@dotnet.itags.org.UserID", SqlDbType.Int).Value =
UserID
End With
sqlConn.Open()
sqlReader = sqlCmd.ExecuteReader
Catch ex As Exception
Throw ex
End Try
Return sqlReader
End Function
End Class
End Namespace
Using vbc, I successfully compiled the above class file into a DLL
named NConnect.dll.
This is the simple stored procedure:
CREATE PROCEDURE NETGetAddress
@dotnet.itags.org.UserID integer
AS
SELECT UserID, Address, City, State, Country, Zip FROM tblUsers WHERE
UserID = @dotnet.itags.org.UserID
The ASPX page uses a user control named 'Address.ascx' which has 5
TextBoxes named txtAddress, txtCity, txtState, txtCountry & txtZip. I
am using the Get & Set statement for creating a property for each of
the TextBoxes like this:
Public Property Address() As String
Get
Address = txtAddress.Text
End Get
Set(ByVal value As String)
txtAddress.Text = value
End Set
End Property
'here comes the other properties
Finally, this is the ASPX page:
<%@dotnet.itags.org. Register TagPrefix="NETConnect" TagName="Address"
Src="NETAddress.ascx" %>
<%@dotnet.itags.org. Import Namespace="NConnect" %>
<%@dotnet.itags.org. Import Namespace="System.Data" %>
<%@dotnet.itags.org. Import Namespace="System.Data.SqlClient" %>
<script runat="server">
Sub Page_Load(....)
Dim boCart As Cart
Dim iUserID As Integer
Dim sqlReader As SqlDataReader
'retrieving the UserID by calling another function
sqlReader = boCart.GetAddress(iUserID)
End Sub
</script>
<form runat="server">
<NETConnect:NETAddress ID="ncBillingAddress" runat="server"/>
</form>
The ASPX page will render the 5 TextBoxes. Now how do I populate the 5
TextBoxes with the records that the stored procedure retrieves for a
particular UserID?OK....this is what I tried in the ASPX page (this ASPX page is named
NETAddress.aspx):
<%@. Register TagPrefix="NETConnect" TagName="Address"
Src="NETAddress.ascx" %>
<%@. Import Namespace="NConnect" %>
<%@. Import Namespace="System.Data" %>
<%@. Import Namespace="System.Data.SqlClient" %>
<script runat="server">
Sub Page_Load(....)
Dim boCart As Cart
Dim iUserID As Integer
Dim sqlReader As SqlDataReader
Dim nAddress As netaddress_ascx
'retrieving the UserID by calling another function
nAddress = Page.LoadControl("NETAddress.ascx")
nAddress.ID = "ncBilling"
pnlAddress.Controls.Add(nAddress)
sqlReader = boCart.GetAddress(iUserID)
Response.Write("Field Count: " & sqlReader.FieldCount)
nAddress.Address = sqlReader.GetString(1)
nAddress.City = sqlReader.GetString(2)
nAddress.StateName = sqlReader.GetString(3)
nAddress.Country = sqlReader.GetString(4)
nAddress.Zip = sqlReader.GetString(5)
End Sub
</script>
<form runat="server">
<asp:Panel ID="pnlAddress" runat="server"/>
</form>
But the above generates this error:
Invalid attempt to read when no data is present.
pointing to
nAddress.Address = sqlReader.GetString(1)
What's causing the error? Note the Response.Write(sqlReader.FieldCount)
line. If I comment out all the GetString lines after this line, then
sqlReader.FieldCount correctly displays the field count as 6. So how
come sqlReader.GetString(1) has no data?
Moreover if I bind the data to a DataList, then also the DataList
renders all the records corresponding to the UserID; so where am I
going wrong?
rn5a@.rediffmail.com wrote:
> This function in a VB class file takes UserID as a parameter & returns
> a SqlDataReader to the calling function which exists in a ASPX page:
> Namespace NConnect
> Public Class Cart
> Private sqlConn As New SqlConnection("....")
> Public Function GetAddress(ByVal UserID As Integer) As
> SqlDataReader
> Dim sqlCmd As SqlCommand
> Dim sqlReader As SqlDataReader
> sqlCmd = New SqlCommand("NETGetAddress", sqlConn)
> sqlCmd.CommandType = CommandType.StoredProcedure
> Try
> With sqlCmd
> .Parameters.Add("@.UserID", SqlDbType.Int).Value =
> UserID
> End With
> sqlConn.Open()
> sqlReader = sqlCmd.ExecuteReader
> Catch ex As Exception
> Throw ex
> End Try
> Return sqlReader
> End Function
> End Class
> End Namespace
> Using vbc, I successfully compiled the above class file into a DLL
> named NConnect.dll.
> This is the simple stored procedure:
> CREATE PROCEDURE NETGetAddress
> @.UserID integer
> AS
> SELECT UserID, Address, City, State, Country, Zip FROM tblUsers WHERE
> UserID = @.UserID
> The ASPX page uses a user control named 'Address.ascx' which has 5
> TextBoxes named txtAddress, txtCity, txtState, txtCountry & txtZip. I
> am using the Get & Set statement for creating a property for each of
> the TextBoxes like this:
> Public Property Address() As String
> Get
> Address = txtAddress.Text
> End Get
> Set(ByVal value As String)
> txtAddress.Text = value
> End Set
> End Property
> 'here comes the other properties
> Finally, this is the ASPX page:
> <%@. Register TagPrefix="NETConnect" TagName="Address"
> src="http://pics.10026.com/?src=NETAddress.ascx" %>
> <%@. Import Namespace="NConnect" %>
> <%@. Import Namespace="System.Data" %>
> <%@. Import Namespace="System.Data.SqlClient" %>
> <script runat="server">
> Sub Page_Load(....)
> Dim boCart As Cart
> Dim iUserID As Integer
> Dim sqlReader As SqlDataReader
> 'retrieving the UserID by calling another function
> sqlReader = boCart.GetAddress(iUserID)
> End Sub
> </script>
> <form runat="server">
> <NETConnect:NETAddress ID="ncBillingAddress" runat="server"/>
> </form>
> The ASPX page will render the 5 TextBoxes. Now how do I populate the 5
> TextBoxes with the records that the stored procedure retrieves for a
> particular UserID?
Well...the mistake I was making was I wasn't looping through the
SqlDataReader using the Read method of the SqlDataReader...
While(sqlReader.Read)
nAddress.Address = sqlReader.GetString(1)
nAddress.City = sqlReader.GetString(2)
nAddress.StateName = sqlReader.GetString(3)
nAddress.Country = sqlReader.GetString(4)
nAddress.Zip = sqlReader.GetString(5)
End While
rn5a@.rediffmail.com wrote:
> OK....this is what I tried in the ASPX page (this ASPX page is named
> NETAddress.aspx):
> <%@. Register TagPrefix="NETConnect" TagName="Address"
> src="http://pics.10026.com/?src=NETAddress.ascx" %>
> <%@. Import Namespace="NConnect" %>
> <%@. Import Namespace="System.Data" %>
> <%@. Import Namespace="System.Data.SqlClient" %>
> <script runat="server">
> Sub Page_Load(....)
> Dim boCart As Cart
> Dim iUserID As Integer
> Dim sqlReader As SqlDataReader
> Dim nAddress As netaddress_ascx
> 'retrieving the UserID by calling another function
> nAddress = Page.LoadControl("NETAddress.ascx")
> nAddress.ID = "ncBilling"
> pnlAddress.Controls.Add(nAddress)
> sqlReader = boCart.GetAddress(iUserID)
> Response.Write("Field Count: " & sqlReader.FieldCount)
> nAddress.Address = sqlReader.GetString(1)
> nAddress.City = sqlReader.GetString(2)
> nAddress.StateName = sqlReader.GetString(3)
> nAddress.Country = sqlReader.GetString(4)
> nAddress.Zip = sqlReader.GetString(5)
> End Sub
> </script>
> <form runat="server">
> <asp:Panel ID="pnlAddress" runat="server"/>
> </form>
> But the above generates this error:
> Invalid attempt to read when no data is present.
> pointing to
> nAddress.Address = sqlReader.GetString(1)
> What's causing the error? Note the Response.Write(sqlReader.FieldCount)
> line. If I comment out all the GetString lines after this line, then
> sqlReader.FieldCount correctly displays the field count as 6. So how
> come sqlReader.GetString(1) has no data?
> Moreover if I bind the data to a DataList, then also the DataList
> renders all the records corresponding to the UserID; so where am I
> going wrong?
>
> rn5a@.rediffmail.com wrote:

Populate TextBox With DB Records

This function in a VB class file takes UserID as a parameter & returns
a SqlDataReader to the calling function which exists in a ASPX page:

Namespace NConnect
Public Class Cart
Private sqlConn As New SqlConnection("....")
Public Function GetAddress(ByVal UserID As Integer) As
SqlDataReader
Dim sqlCmd As SqlCommand
Dim sqlReader As SqlDataReader

sqlCmd = New SqlCommand("NETGetAddress", sqlConn)
sqlCmd.CommandType = CommandType.StoredProcedure

Try
With sqlCmd
.Parameters.Add("@dotnet.itags.org.UserID", SqlDbType.Int).Value =
UserID
End With

sqlConn.Open()
sqlReader = sqlCmd.ExecuteReader
Catch ex As Exception
Throw ex
End Try

Return sqlReader
End Function
End Class
End Namespace

Using vbc, I successfully compiled the above class file into a DLL
named NConnect.dll.

This is the simple stored procedure:

CREATE PROCEDURE NETGetAddress
@dotnet.itags.org.UserID integer
AS
SELECT UserID, Address, City, State, Country, Zip FROM tblUsers WHERE
UserID = @dotnet.itags.org.UserID

The ASPX page uses a user control named 'Address.ascx' which has 5
TextBoxes named txtAddress, txtCity, txtState, txtCountry & txtZip. I
am using the Get & Set statement for creating a property for each of
the TextBoxes like this:

Public Property Address() As String
Get
Address = txtAddress.Text
End Get
Set(ByVal value As String)
txtAddress.Text = value
End Set
End Property

'here comes the other properties

Finally, this is the ASPX page:

<%@dotnet.itags.org. Register TagPrefix="NETConnect" TagName="Address"
Src="NETAddress.ascx" %>
<%@dotnet.itags.org. Import Namespace="NConnect" %>
<%@dotnet.itags.org. Import Namespace="System.Data" %>
<%@dotnet.itags.org. Import Namespace="System.Data.SqlClient" %>

<script runat="server">
Sub Page_Load(....)
Dim boCart As Cart
Dim iUserID As Integer
Dim sqlReader As SqlDataReader

'retrieving the UserID by calling another function
sqlReader = boCart.GetAddress(iUserID)
End Sub
</script>

<form runat="server">
<NETConnect:NETAddress ID="ncBillingAddress" runat="server"/>
</form>

The ASPX page will render the 5 TextBoxes. Now how do I populate the 5
TextBoxes with the records that the stored procedure retrieves for a
particular UserID?OK....this is what I tried in the ASPX page (this ASPX page is named
NETAddress.aspx):

<%@. Register TagPrefix="NETConnect" TagName="Address"
Src="NETAddress.ascx" %>
<%@. Import Namespace="NConnect" %>
<%@. Import Namespace="System.Data" %>
<%@. Import Namespace="System.Data.SqlClient" %>

<script runat="server">
Sub Page_Load(....)
Dim boCart As Cart
Dim iUserID As Integer
Dim sqlReader As SqlDataReader
Dim nAddress As netaddress_ascx

'retrieving the UserID by calling another function

nAddress = Page.LoadControl("NETAddress.ascx")
nAddress.ID = "ncBilling"
pnlAddress.Controls.Add(nAddress)

sqlReader = boCart.GetAddress(iUserID)

Response.Write("Field Count: " & sqlReader.FieldCount)
nAddress.Address = sqlReader.GetString(1)
nAddress.City = sqlReader.GetString(2)
nAddress.StateName = sqlReader.GetString(3)
nAddress.Country = sqlReader.GetString(4)
nAddress.Zip = sqlReader.GetString(5)
End Sub
</script>
<form runat="server">
<asp:Panel ID="pnlAddress" runat="server"/>
</form>

But the above generates this error:

Invalid attempt to read when no data is present.

pointing to

nAddress.Address = sqlReader.GetString(1)

What's causing the error? Note the Response.Write(sqlReader.FieldCount)
line. If I comment out all the GetString lines after this line, then
sqlReader.FieldCount correctly displays the field count as 6. So how
come sqlReader.GetString(1) has no data?

Moreover if I bind the data to a DataList, then also the DataList
renders all the records corresponding to the UserID; so where am I
going wrong?

rn5a@.rediffmail.com wrote:

Quote:

Originally Posted by

This function in a VB class file takes UserID as a parameter & returns
a SqlDataReader to the calling function which exists in a ASPX page:
>
Namespace NConnect
Public Class Cart
Private sqlConn As New SqlConnection("....")
Public Function GetAddress(ByVal UserID As Integer) As
SqlDataReader
Dim sqlCmd As SqlCommand
Dim sqlReader As SqlDataReader
>
sqlCmd = New SqlCommand("NETGetAddress", sqlConn)
sqlCmd.CommandType = CommandType.StoredProcedure
>
Try
With sqlCmd
.Parameters.Add("@.UserID", SqlDbType.Int).Value =
UserID
End With
>
sqlConn.Open()
sqlReader = sqlCmd.ExecuteReader
Catch ex As Exception
Throw ex
End Try
>
Return sqlReader
End Function
End Class
End Namespace
>
Using vbc, I successfully compiled the above class file into a DLL
named NConnect.dll.
>
This is the simple stored procedure:
>
CREATE PROCEDURE NETGetAddress
@.UserID integer
AS
SELECT UserID, Address, City, State, Country, Zip FROM tblUsers WHERE
UserID = @.UserID
>
The ASPX page uses a user control named 'Address.ascx' which has 5
TextBoxes named txtAddress, txtCity, txtState, txtCountry & txtZip. I
am using the Get & Set statement for creating a property for each of
the TextBoxes like this:
>
Public Property Address() As String
Get
Address = txtAddress.Text
End Get
Set(ByVal value As String)
txtAddress.Text = value
End Set
End Property
>
'here comes the other properties
>
Finally, this is the ASPX page:
>
<%@. Register TagPrefix="NETConnect" TagName="Address"
Src="NETAddress.ascx" %>
<%@. Import Namespace="NConnect" %>
<%@. Import Namespace="System.Data" %>
<%@. Import Namespace="System.Data.SqlClient" %>
>
<script runat="server">
Sub Page_Load(....)
Dim boCart As Cart
Dim iUserID As Integer
Dim sqlReader As SqlDataReader
>
'retrieving the UserID by calling another function
sqlReader = boCart.GetAddress(iUserID)
End Sub
</script>
>
<form runat="server">
<NETConnect:NETAddress ID="ncBillingAddress" runat="server"/>
</form>
>
The ASPX page will render the 5 TextBoxes. Now how do I populate the 5
TextBoxes with the records that the stored procedure retrieves for a
particular UserID?


Well...the mistake I was making was I wasn't looping through the
SqlDataReader using the Read method of the SqlDataReader...

While(sqlReader.Read)
nAddress.Address = sqlReader.GetString(1)
nAddress.City = sqlReader.GetString(2)
nAddress.StateName = sqlReader.GetString(3)
nAddress.Country = sqlReader.GetString(4)
nAddress.Zip = sqlReader.GetString(5)
End While

rn5a@.rediffmail.com wrote:

Quote:

Originally Posted by

OK....this is what I tried in the ASPX page (this ASPX page is named
NETAddress.aspx):
>
<%@. Register TagPrefix="NETConnect" TagName="Address"
Src="NETAddress.ascx" %>
<%@. Import Namespace="NConnect" %>
<%@. Import Namespace="System.Data" %>
<%@. Import Namespace="System.Data.SqlClient" %>
>
<script runat="server">
Sub Page_Load(....)
Dim boCart As Cart
Dim iUserID As Integer
Dim sqlReader As SqlDataReader
Dim nAddress As netaddress_ascx
>
'retrieving the UserID by calling another function
>
nAddress = Page.LoadControl("NETAddress.ascx")
nAddress.ID = "ncBilling"
pnlAddress.Controls.Add(nAddress)
>
sqlReader = boCart.GetAddress(iUserID)
>
Response.Write("Field Count: " & sqlReader.FieldCount)
nAddress.Address = sqlReader.GetString(1)
nAddress.City = sqlReader.GetString(2)
nAddress.StateName = sqlReader.GetString(3)
nAddress.Country = sqlReader.GetString(4)
nAddress.Zip = sqlReader.GetString(5)
End Sub
</script>
<form runat="server">
<asp:Panel ID="pnlAddress" runat="server"/>
</form>
>
But the above generates this error:
>
Invalid attempt to read when no data is present.
>
pointing to
>
nAddress.Address = sqlReader.GetString(1)
>
What's causing the error? Note the Response.Write(sqlReader.FieldCount)
line. If I comment out all the GetString lines after this line, then
sqlReader.FieldCount correctly displays the field count as 6. So how
come sqlReader.GetString(1) has no data?
>
Moreover if I bind the data to a DataList, then also the DataList
renders all the records corresponding to the UserID; so where am I
going wrong?
>
>
rn5a@.rediffmail.com wrote:

Quote:

Originally Posted by

This function in a VB class file takes UserID as a parameter & returns
a SqlDataReader to the calling function which exists in a ASPX page:

Namespace NConnect
Public Class Cart
Private sqlConn As New SqlConnection("....")
Public Function GetAddress(ByVal UserID As Integer) As
SqlDataReader
Dim sqlCmd As SqlCommand
Dim sqlReader As SqlDataReader

sqlCmd = New SqlCommand("NETGetAddress", sqlConn)
sqlCmd.CommandType = CommandType.StoredProcedure

Try
With sqlCmd
.Parameters.Add("@.UserID", SqlDbType.Int).Value =
UserID
End With

sqlConn.Open()
sqlReader = sqlCmd.ExecuteReader
Catch ex As Exception
Throw ex
End Try

Return sqlReader
End Function
End Class
End Namespace

Using vbc, I successfully compiled the above class file into a DLL
named NConnect.dll.

This is the simple stored procedure:

CREATE PROCEDURE NETGetAddress
@.UserID integer
AS
SELECT UserID, Address, City, State, Country, Zip FROM tblUsers WHERE
UserID = @.UserID

The ASPX page uses a user control named 'Address.ascx' which has 5
TextBoxes named txtAddress, txtCity, txtState, txtCountry & txtZip. I
am using the Get & Set statement for creating a property for each of
the TextBoxes like this:

Public Property Address() As String
Get
Address = txtAddress.Text
End Get
Set(ByVal value As String)
txtAddress.Text = value
End Set
End Property

'here comes the other properties

Finally, this is the ASPX page:

<%@. Register TagPrefix="NETConnect" TagName="Address"
src="http://pics.10026.com/?src=NETAddress.ascx" %>
<%@. Import Namespace="NConnect" %>
<%@. Import Namespace="System.Data" %>
<%@. Import Namespace="System.Data.SqlClient" %>

<script runat="server">
Sub Page_Load(....)
Dim boCart As Cart
Dim iUserID As Integer
Dim sqlReader As SqlDataReader

'retrieving the UserID by calling another function
sqlReader = boCart.GetAddress(iUserID)
End Sub
</script>

<form runat="server">
<NETConnect:NETAddress ID="ncBillingAddress" runat="server"/>
</form>

The ASPX page will render the 5 TextBoxes. Now how do I populate the 5
TextBoxes with the records that the stored procedure retrieves for a
particular UserID?

Friday, March 16, 2012

Populating Controls - Form Load Dynamically

hi all,
how can I populate one aspx form when page is loading based on page ID? for
example:
loading page A (to search for VB code) would display labels and texboxes,
dropdown lists all related to VB, plus the address bar would show something
like this: www.somethinghere?id=3
and if you change number 3 from the address bar to (for example) 34 or 71
you would get different page with the same formatting like I.e:
www.somethinghere?id=34 would load the page related to C# topics and all
labels and texboxes and dropdown lists related to C# OR
www.somethinghere?id=71 would load the page related to ASP.NET for example
and labels and textboxes would be populated according to ASP.NET and so
on...

my question is, how do they do that? they must assign an ID number for each
topic but then how they populate all controls on that ONE page accordingly?

I am very much interested in this approach and wants to know how its done
and how can I get more info about it. I think its better than duplicating
pages if you were going to use them over and over?

what do you think?

please let me know

thanksid=XX part of the url is available as Request.QueryString.
Request.QueryString["id"] for www.somethinghere?id=71 will return "71".
PageLoad event code can read the id and setup the page controls accordingly.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]

"netasp" <netasp@.newsgroups.nospamwrote in message
news:O6fQ523xGHA.3488@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

hi all,
how can I populate one aspx form when page is loading based on page ID?
for example:
loading page A (to search for VB code) would display labels and texboxes,
dropdown lists all related to VB, plus the address bar would show
something like this: www.somethinghere?id=3
>
and if you change number 3 from the address bar to (for example) 34 or 71
you would get different page with the same formatting like I.e:
www.somethinghere?id=34 would load the page related to C# topics and all
labels and texboxes and dropdown lists related to C# OR
www.somethinghere?id=71 would load the page related to ASP.NET for example
and labels and textboxes would be populated according to ASP.NET and so
on...
>
my question is, how do they do that? they must assign an ID number for
each topic but then how they populate all controls on that ONE page
accordingly?
>
I am very much interested in this approach and wants to know how its done
and how can I get more info about it. I think its better than duplicating
pages if you were going to use them over and over?
>
what do you think?
>
please let me know
>
thanks
>
>


thanks Eliyahu for your reply,

does this method considered to be a good or bad practice with visual studio
2005? because I also have seen some other web applications using different
pages for each category page, their address bar would show aspx pages I.e
employee.aspx, manager.aspx, supervisor.aspx instead of loading everything
into one template page.

I just want to know what is the best practice and recommendation for such a
scenario?

thanks again

"Eliyahu Goldin" <REMOVEALLCAPITALSeEgGoldDinN@.mMvVpPsS.orgwrote in
message news:%23mXBFJ5xGHA.4732@.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by

id=XX part of the url is available as Request.QueryString.
Request.QueryString["id"] for www.somethinghere?id=71 will return "71".
PageLoad event code can read the id and setup the page controls
accordingly.
>
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
>
"netasp" <netasp@.newsgroups.nospamwrote in message
news:O6fQ523xGHA.3488@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

>hi all,
>how can I populate one aspx form when page is loading based on page ID?
>for example:
>loading page A (to search for VB code) would display labels and texboxes,
>dropdown lists all related to VB, plus the address bar would show
>something like this: www.somethinghere?id=3
>>
>and if you change number 3 from the address bar to (for example) 34 or 71
>you would get different page with the same formatting like I.e:
>www.somethinghere?id=34 would load the page related to C# topics and all
>labels and texboxes and dropdown lists related to C# OR
>www.somethinghere?id=71 would load the page related to ASP.NET for
>example and labels and textboxes would be populated according to ASP.NET
>and so on...
>>
>my question is, how do they do that? they must assign an ID number for
>each topic but then how they populate all controls on that ONE page
>accordingly?
>>
>I am very much interested in this approach and wants to know how its done
>and how can I get more info about it. I think its better than duplicating
>pages if you were going to use them over and over?
>>
>what do you think?
>>
>please let me know
>>
>thanks
>>
>>


>
>


Hello Netasp,

In ASP.NET, dynamically creating webcontrols is naturally supported. Here
are some web articles introducing this:

#HOW TO: Dynamically Create Controls in ASP.NET by Using Visual C# .NET
http://support.microsoft.com/kb/317794/EN-US/
#Adding Controls to a Web Forms Page Programmatically
http://authors.aspalliance.com/aspx...dingcontrolstow
ebformspageprogrammatically.aspx

#How to: Add Controls to an ASP.NET Web Page Programmatically
http://msdn2.microsoft.com/en-us/library/kyt0fzt1.aspx
for your scenario, you want to generate two page UI for different client
user requests(search for VB or c#), I think you need to consider the
following things:

Which one is more important for our application, flexibiilty or
performance?

When we dynamically create the page UI depend on different client requests,
it make the page very flexible and easy to extend when you want to add
additional UI template(such as search for J#...). However, the drawback
here is that dynamically creating control will add performance overhead
which is less efficient than statically compiled and loaded page/controls.
Also, making the page UI dynamically generated will make the line of code
in your page increase significantly.

IMO, for those pages which as definitely different code logic and business
purpose or the UI differ from each other obviously, I would recommend you
create separate page for each one.

If the UI of those pages are similar and easy to be templated, you can
consider creating a page to dynamically generate UI.

Please feel free to let me know if you have any further questions.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

This posting is provided "AS IS" with no warranties, and confers no rights.
thank you Steven for your reply,

how about this:
I create the page and add all the necessary controls to it, dropdown list,
an image box, labels and some textboxes (with generic names) -// so there is
not an overhead of creating controls dynamically

then, if the user clicks the ASP.NET link for example (and lets say it has
been assigned ID=1) then I go to my database and load the appropriate
control names and images for the C# page! OR if the user clicks C# link
(which lets also assume it has been assigned to ID=21) then I will load from
another table all the appropriate names for labels, textboxes and images for
that C# page.

what do you think? would that cut half of my overhead expenses? considering
the controls are already been created?

I would love to hear your input on this approach.

thank you very much for the links

"Steven Cheng[MSFT]" <stcheng@.online.microsoft.comwrote in message
news:hp8bsa$xGHA.4220@.TK2MSFTNGXA01.phx.gbl...

Quote:

Originally Posted by

Hello Netasp,
>
In ASP.NET, dynamically creating webcontrols is naturally supported. Here
are some web articles introducing this:
>
#HOW TO: Dynamically Create Controls in ASP.NET by Using Visual C# .NET
http://support.microsoft.com/kb/317794/EN-US/
>
#Adding Controls to a Web Forms Page Programmatically
http://authors.aspalliance.com/aspx...dingcontrolstow
ebformspageprogrammatically.aspx
>
#How to: Add Controls to an ASP.NET Web Page Programmatically
http://msdn2.microsoft.com/en-us/library/kyt0fzt1.aspx
>
for your scenario, you want to generate two page UI for different client
user requests(search for VB or c#), I think you need to consider the
following things:
>
Which one is more important for our application, flexibiilty or
performance?
>
When we dynamically create the page UI depend on different client
requests,
it make the page very flexible and easy to extend when you want to add
additional UI template(such as search for J#...). However, the drawback
here is that dynamically creating control will add performance overhead
which is less efficient than statically compiled and loaded page/controls.
Also, making the page UI dynamically generated will make the line of code
in your page increase significantly.
>
IMO, for those pages which as definitely different code logic and business
purpose or the UI differ from each other obviously, I would recommend you
create separate page for each one.
>
If the UI of those pages are similar and easy to be templated, you can
consider creating a page to dynamically generate UI.
>
Please feel free to let me know if you have any further questions.
>
>
Sincerely,
>
Steven Cheng
>
Microsoft MSDN Online Support Lead
>
>
>
This posting is provided "AS IS" with no warranties, and confers no
rights.
>


Thanks for your reply Netasp,

As for the new idea you mentioned, do you mean you predefine all the
controls on the page and assigned fixed ID for each one. and dynamically
load their string resources( such as Text ...) from file or database and
assign to their "Text" property? If this is the case, I think it doable.

Of course, if the controls are defined at design-time, it will save lots of
dynamic control creating and loading overhead.

Please let me know if you have any further questions.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

This posting is provided "AS IS" with no warranties, and confers no rights.
thanks Steven for your reply,

yeah, this is very much the idea, and I think its better than creating more
than one aspx page that does exactly the same thing.

it seems doable so far, and I will pick up any issues as I advance.

thanks for your help.

best regard,

"Steven Cheng[MSFT]" <stcheng@.online.microsoft.comwrote in message
news:9Q8DZ2nyGHA.4616@.TK2MSFTNGXA01.phx.gbl...

Quote:

Originally Posted by

Thanks for your reply Netasp,
>
As for the new idea you mentioned, do you mean you predefine all the
controls on the page and assigned fixed ID for each one. and dynamically
load their string resources( such as Text ...) from file or database and
assign to their "Text" property? If this is the case, I think it doable.
>
Of course, if the controls are defined at design-time, it will save lots
of
dynamic control creating and loading overhead.
>
Please let me know if you have any further questions.
>
Sincerely,
>
Steven Cheng
>
Microsoft MSDN Online Support Lead
>
>
This posting is provided "AS IS" with no warranties, and confers no
rights.
>
>


Thanks for the followup Netasp,

Yes, this is a good idea. Actually, what you do is just how ASP.NET
application do localization support for web pages. ASP.NET support creating
resource files for each page or the whole application and we can load
string or other resource(like image, files) from resource file according
different CultureInfo. So for your case here, instead of depending on
CultureInfo, your page's resource are depend on other criteria.

Please feel free to post here if you meet any further problem.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

This posting is provided "AS IS" with no warranties, and confers no rights.
now I have one final question,
what is the best reliable way of loading a control value from a database?
lets say I have label1 already sitting in my webform how can I load its
content "Books" from a table1 in sql 2005 database?

do I use a normal adapter to loop through? is there a good examples
illustrating how to accomplish that?

thanks
"netasp" <netasp@.newsgroups.nospamwrote in message
news:%235MSXCtyGHA.284@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

thanks Steven for your reply,
>
yeah, this is very much the idea, and I think its better than creating
more than one aspx page that does exactly the same thing.
>
it seems doable so far, and I will pick up any issues as I advance.
>
thanks for your help.
>
best regard,
>
"Steven Cheng[MSFT]" <stcheng@.online.microsoft.comwrote in message
news:9Q8DZ2nyGHA.4616@.TK2MSFTNGXA01.phx.gbl...

Quote:

Originally Posted by

>Thanks for your reply Netasp,
>>
>As for the new idea you mentioned, do you mean you predefine all the
>controls on the page and assigned fixed ID for each one. and dynamically
>load their string resources( such as Text ...) from file or database
>and
>assign to their "Text" property? If this is the case, I think it
>doable.
>>
>Of course, if the controls are defined at design-time, it will save lots
>of
>dynamic control creating and loading overhead.
>>
>Please let me know if you have any further questions.
>>
>Sincerely,
>>
>Steven Cheng
>>
>Microsoft MSDN Online Support Lead
>>
>>
>This posting is provided "AS IS" with no warranties, and confers no
>rights.
>>
>>


>
>


Hi Netasp,

how you'll read the static data from database depend on how will you use
them. If you will only load them at each page's startup time and will
requrey database if require them later, I suggest you use Sqlcommand +
DataReader to query the data since this will have better performance.

If you will load the data and also cached them in local memory for later
use, you can consider use TableAdpater and return them in the form of
DataTable, Dataset ...

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

This posting is provided "AS IS" with no warranties, and confers no rights.