Saturday, March 31, 2012
Set a value to a hidden field in a web page
I have a problem when using a hidden field to send a value to the server.
Below you can see my code in simplyfied versions.
What I'm trying to do is:
1. The user browses for a picture at the network from their computer using
control File1.
2. The user clickes the button Commit picture (with id CliBtn)
a. The script is running at the client to get the sharename of the file
selected
b. The script should update a picture shown (the code below just shows
the label with the path)
c. The code-behind should then save all values in a database.
The problem appear when I'm trying to set the value to the hide control, so
I am doing something wrong.
I'm not so used to web developing, so please give me some help here, with
code please.
Regards Magnus
--
Code-behind page in C#
--
void Page_Load(object sender, EventArgs e)
{
HtmlInputHidden hide = new HtmlInputHidden();
hide.ID = "hide";
hide.Value = "Hidden Text";
sURL = Request.Form["hide"].ToString();
Label11.Text = sURL;
}
--
.ASPX page
--
<head>
<title>Untitled Page</title>
<script language=vbscript>
function getpicvb()
dim javatext
javatext = document.getElementById("File1").getAttribute("value")
dim fso
set FSO = CreateObject("Scripting.FileSystemObject")
dim drive
set drive =
FSO.GetDrive(FSO.GetDriveName(FSO.GetAbsolutePathName(javatext)))
javatext = drive.ShareName
'hide.value = javatext ' this row doesn't work
alert(javatext)
end function
</script>
</head>
<body>
<input id="File1" type="file" />
<input id="CliBtn" value="Commit picture" onclick="getpicvb() " type=submit
/>
<asp:Label ID="Label11" Runat="server" Text="Label"></asp:Label>
<input type=hidden id=hide />
</body>
----
---
"Brock Allen" <ballen@dotnet.itags.org.NOSPAMdevelop.com> wrote in message
news:444437632489320772241920@dotnet.itags.org.msnews.microsoft.com...
> Make a hidden field (via Page.RegisterHiddenField) and have the javascript
> write the value to the hidden. In the server, fetch the value via
Request.Form["YourFieldID"]
> -Brock
> DevelopMentor
> http://staff.develop.com/ballen
>
>
>
>Controlled envionement ? What is the exact problme you have (you have always
"Hidden Text" server side ?
In particular fso is not supposed to work without tweaking security
settings. ARe you sure itjust doesn't fails silently...
Also you always change the value of the "hide" field when the page loads...
Try to do not "if (!Ispostback)"...
Patrice
"Magnus Blomberg" <magnus.blomberg@.skanska.se> a crit dans le message de
news:uTXsgPOQFHA.1528@.TK2MSFTNGP09.phx.gbl...
> Hello!
> I have a problem when using a hidden field to send a value to the server.
> Below you can see my code in simplyfied versions.
> What I'm trying to do is:
> 1. The user browses for a picture at the network from their computer using
> control File1.
> 2. The user clickes the button Commit picture (with id CliBtn)
> a. The script is running at the client to get the sharename of the
file
> selected
> b. The script should update a picture shown (the code below just shows
> the label with the path)
> c. The code-behind should then save all values in a database.
> The problem appear when I'm trying to set the value to the hide control,
so
> I am doing something wrong.
> I'm not so used to web developing, so please give me some help here, with
> code please.
> Regards Magnus
> --
> Code-behind page in C#
> --
> void Page_Load(object sender, EventArgs e)
> {
> HtmlInputHidden hide = new HtmlInputHidden();
> hide.ID = "hide";
> hide.Value = "Hidden Text";
> sURL = Request.Form["hide"].ToString();
> Label11.Text = sURL;
> }
> --
> .ASPX page
> --
> <head>
> <title>Untitled Page</title>
> <script language=vbscript>
> function getpicvb()
> dim javatext
> javatext = document.getElementById("File1").getAttribute("value")
> dim fso
> set FSO = CreateObject("Scripting.FileSystemObject")
> dim drive
> set drive =
> FSO.GetDrive(FSO.GetDriveName(FSO.GetAbsolutePathName(javatext)))
> javatext = drive.ShareName
> 'hide.value = javatext ' this row doesn't work
> alert(javatext)
> end function
> </script>
> </head>
> <body>
> <input id="File1" type="file" />
> <input id="CliBtn" value="Commit picture" onclick="getpicvb() "
type=submit
> />
> <asp:Label ID="Label11" Runat="server" Text="Label"></asp:Label>
> <input type=hidden id=hide />
> </body>
> ----
--
> ---
> "Brock Allen" <ballen@.NOSPAMdevelop.com> wrote in message
> news:444437632489320772241920@.msnews.microsoft.com...
javascript
> Request.Form["YourFieldID"]
>
>
Magnus what are u trying to do'
Vbscript,C#'?
*** Sent via Developersdex http://www.examnotes.net ***
Hello and thanks for your answer.
Well, I thought fso was not a common way to solve this, but since this is
for a Intranet, I think I can theak the security anyway. If you have a
better solution for this issue I'll be glad to here it.
I'm not sure what silent failure does mean, but I think that is what I get.
I get no error message, but the alert row is never executed when the
hide.value = javatext is run.
The problem does not appear when working with fso. It appears when trying to
set the hide object.
I am familiar to the (!IsPostBack) command, so I will take care of that in
my full code.
My code in this forum is shrinked.
Regards Magnus
"Patrice" <nobody@.nowhere.com> wrote in message
news:#Xio4aOQFHA.3076@.TK2MSFTNGP14.phx.gbl...
> Controlled envionement ? What is the exact problme you have (you have
always
> "Hidden Text" server side ?
> In particular fso is not supposed to work without tweaking security
> settings. ARe you sure itjust doesn't fails silently...
> Also you always change the value of the "hide" field when the page
loads...
> Try to do not "if (!Ispostback)"...
> Patrice
> --
> "Magnus Blomberg" <magnus.blomberg@.skanska.se> a crit dans le message de
> news:uTXsgPOQFHA.1528@.TK2MSFTNGP09.phx.gbl...
server.
using
> file
shows
> so
with
document.getElementById("File1").getAttribute("value")
> type=submit
> ----
> --
> javascript
This
basics?
>
Ok, so this line is never executed.
Check if the fso object is set. Do you have yet tweaked security ?
If I remember when security is not tweaked , it fails without any warning
(as anyway it 's not supposed to work).
What do you want to do ? You can use an input type=file to get the name
server side even if you don't want to upload this file. This way you
wouldn't need to copy this value in an hidden field.
Also I don't really see how it works. The server could perhaps not have the
same netwrok path available.
Depneidng on what you wan to do with this file, I would upload it server
file to do the intended processing...
Good luck
Patrice
"Magnus Blomberg" <magnus.blomberg@.skanska.se> a crit dans le message de
news:%23GCvfKPQFHA.3988@.tk2msftngp13.phx.gbl...
> Hello and thanks for your answer.
> Well, I thought fso was not a common way to solve this, but since this is
> for a Intranet, I think I can theak the security anyway. If you have a
> better solution for this issue I'll be glad to here it.
> I'm not sure what silent failure does mean, but I think that is what I
get.
> I get no error message, but the alert row is never executed when the
> hide.value = javatext is run.
> The problem does not appear when working with fso. It appears when trying
to
> set the hide object.
> I am familiar to the (!IsPostBack) command, so I will take care of that in
> my full code.
> My code in this forum is shrinked.
> Regards Magnus
>
> "Patrice" <nobody@.nowhere.com> wrote in message
> news:#Xio4aOQFHA.3076@.TK2MSFTNGP14.phx.gbl...
> always
> loads...
de
> server.
> using
> shows
control,
> with
> document.getElementById("File1").getAttribute("value")
> ----
> This
> basics?
>
Set a value to a hidden field in a web page
I have a problem when using a hidden field to send a value to the server.
Below you can see my code in simplyfied versions.
What I'm trying to do is:
1. The user browses for a picture at the network from their computer using
control File1.
2. The user clickes the button Commit picture (with id CliBtn)
a. The script is running at the client to get the sharename of the file
selected
b. The script should update a picture shown (the code below just shows
the label with the path)
c. The code-behind should then save all values in a database.
The problem appear when I'm trying to set the value to the hide control, so
I am doing something wrong.
I'm not so used to web developing, so please give me some help here, with
code please.
Regards Magnus
--------
Code-behind page in C#
--------
void Page_Load(object sender, EventArgs e)
{
HtmlInputHidden hide = new HtmlInputHidden();
hide.ID = "hide";
hide.Value = "Hidden Text";
sURL = Request.Form["hide"].ToString();
Label11.Text = sURL;
}
--------
..ASPX page
--------
<head>
<title>Untitled Page</title>
<script language=vbscript>
function getpicvb()
dim javatext
javatext = document.getElementById("File1").getAttribute("value")
dim fso
set FSO = CreateObject("Scripting.FileSystemObject")
dim drive
set drive =
FSO.GetDrive(FSO.GetDriveName(FSO.GetAbsolutePathN ame(javatext)))
javatext = drive.ShareName
'hide.value = javatext ' this row doesn't work
alert(javatext)
end function
</script>
</head>
<body>
<input id="File1" type="file" />
<input id="CliBtn" value="Commit picture" onclick="getpicvb() " type=submit
/>
<asp:Label ID="Label11" Runat="server" Text="Label"></asp:Label>
<input type=hidden id=hide />
</body>
-----------------------
---------------
"Brock Allen" <ballen@dotnet.itags.org.NOSPAMdevelop.com> wrote in message
news:444437632489320772241920@dotnet.itags.org.msnews.microsoft.com ...
> Make a hidden field (via Page.RegisterHiddenField) and have the javascript
> write the value to the hidden. In the server, fetch the value via
Request.Form["YourFieldID"]
> -Brock
> DevelopMentor
> http://staff.develop.com/ballen
>
> > Hello!
> > I have a client javascript that generates a string (like below). This
> > string should then be used by server code (in this case a function
> > called run).
> > <script language=javascript>
> > function getpic()
> > { string s;
> > s = document.getElementById("File1").getAttribute("value");
> > <% run(s); %>
> > }
> > I think this would be rather common, so maybe I'm missing some basics?
> > Regards MagnusControlled envionement ? What is the exact problme you have (you have always
"Hidden Text" server side ?
In particular fso is not supposed to work without tweaking security
settings. ARe you sure itjust doesn't fails silently...
Also you always change the value of the "hide" field when the page loads...
Try to do not "if (!Ispostback)"...
Patrice
--
"Magnus Blomberg" <magnus.blomberg@.skanska.se> a crit dans le message de
news:uTXsgPOQFHA.1528@.TK2MSFTNGP09.phx.gbl...
> Hello!
> I have a problem when using a hidden field to send a value to the server.
> Below you can see my code in simplyfied versions.
> What I'm trying to do is:
> 1. The user browses for a picture at the network from their computer using
> control File1.
> 2. The user clickes the button Commit picture (with id CliBtn)
> a. The script is running at the client to get the sharename of the
file
> selected
> b. The script should update a picture shown (the code below just shows
> the label with the path)
> c. The code-behind should then save all values in a database.
> The problem appear when I'm trying to set the value to the hide control,
so
> I am doing something wrong.
> I'm not so used to web developing, so please give me some help here, with
> code please.
> Regards Magnus
> --------
> Code-behind page in C#
> --------
> void Page_Load(object sender, EventArgs e)
> {
> HtmlInputHidden hide = new HtmlInputHidden();
> hide.ID = "hide";
> hide.Value = "Hidden Text";
> sURL = Request.Form["hide"].ToString();
> Label11.Text = sURL;
> }
> --------
> .ASPX page
> --------
> <head>
> <title>Untitled Page</title>
> <script language=vbscript>
> function getpicvb()
> dim javatext
> javatext = document.getElementById("File1").getAttribute("value")
> dim fso
> set FSO = CreateObject("Scripting.FileSystemObject")
> dim drive
> set drive =
> FSO.GetDrive(FSO.GetDriveName(FSO.GetAbsolutePathN ame(javatext)))
> javatext = drive.ShareName
> 'hide.value = javatext ' this row doesn't work
> alert(javatext)
> end function
> </script>
> </head>
> <body>
> <input id="File1" type="file" />
> <input id="CliBtn" value="Commit picture" onclick="getpicvb() "
type=submit
> />
> <asp:Label ID="Label11" Runat="server" Text="Label"></asp:Label>
> <input type=hidden id=hide />
> </body>
> -----------------------
--
> ---------------
> "Brock Allen" <ballen@.NOSPAMdevelop.com> wrote in message
> news:444437632489320772241920@.msnews.microsoft.com ...
> > Make a hidden field (via Page.RegisterHiddenField) and have the
javascript
> > write the value to the hidden. In the server, fetch the value via
> Request.Form["YourFieldID"]
> > -Brock
> > DevelopMentor
> > http://staff.develop.com/ballen
> > > Hello!
> > > > I have a client javascript that generates a string (like below). This
> > > string should then be used by server code (in this case a function
> > > called run).
> > > > <script language=javascript>
> > > function getpic()
> > > { string s;
> > > s = document.getElementById("File1").getAttribute("value");
> > > <% run(s); %>
> > > }
> > > I think this would be rather common, so maybe I'm missing some basics?
> > > Regards Magnus
>
Magnus what are u trying to do??
Vbscript,C#???
*** Sent via Developersdex http://www.developersdex.com ***
Hello and thanks for your answer.
Well, I thought fso was not a common way to solve this, but since this is
for a Intranet, I think I can theak the security anyway. If you have a
better solution for this issue I'll be glad to here it.
I'm not sure what silent failure does mean, but I think that is what I get.
I get no error message, but the alert row is never executed when the
hide.value = javatext is run.
The problem does not appear when working with fso. It appears when trying to
set the hide object.
I am familiar to the (!IsPostBack) command, so I will take care of that in
my full code.
My code in this forum is shrinked.
Regards Magnus
"Patrice" <nobody@.nowhere.com> wrote in message
news:#Xio4aOQFHA.3076@.TK2MSFTNGP14.phx.gbl...
> Controlled envionement ? What is the exact problme you have (you have
always
> "Hidden Text" server side ?
> In particular fso is not supposed to work without tweaking security
> settings. ARe you sure itjust doesn't fails silently...
> Also you always change the value of the "hide" field when the page
loads...
> Try to do not "if (!Ispostback)"...
> Patrice
> --
> "Magnus Blomberg" <magnus.blomberg@.skanska.se> a crit dans le message de
> news:uTXsgPOQFHA.1528@.TK2MSFTNGP09.phx.gbl...
> > Hello!
> > I have a problem when using a hidden field to send a value to the
server.
> > Below you can see my code in simplyfied versions.
> > What I'm trying to do is:
> > 1. The user browses for a picture at the network from their computer
using
> > control File1.
> > 2. The user clickes the button Commit picture (with id CliBtn)
> > a. The script is running at the client to get the sharename of the
> file
> > selected
> > b. The script should update a picture shown (the code below just
shows
> > the label with the path)
> > c. The code-behind should then save all values in a database.
> > The problem appear when I'm trying to set the value to the hide control,
> so
> > I am doing something wrong.
> > I'm not so used to web developing, so please give me some help here,
with
> > code please.
> > Regards Magnus
> > --------
> > Code-behind page in C#
> > --------
> > void Page_Load(object sender, EventArgs e)
> > {
> > HtmlInputHidden hide = new HtmlInputHidden();
> > hide.ID = "hide";
> > hide.Value = "Hidden Text";
> > sURL = Request.Form["hide"].ToString();
> > Label11.Text = sURL;
> > }
> > --------
> > .ASPX page
> > --------
> > <head>
> > <title>Untitled Page</title>
> > <script language=vbscript>
> > function getpicvb()
> > dim javatext
> > javatext =
document.getElementById("File1").getAttribute("value")
> > dim fso
> > set FSO = CreateObject("Scripting.FileSystemObject")
> > dim drive
> > set drive =
> > FSO.GetDrive(FSO.GetDriveName(FSO.GetAbsolutePathN ame(javatext)))
> > javatext = drive.ShareName
> > 'hide.value = javatext ' this row doesn't work
> > alert(javatext)
> > end function
> > </script>
> > </head>
> > <body>
> > <input id="File1" type="file" />
> > <input id="CliBtn" value="Commit picture" onclick="getpicvb() "
> type=submit
> > />
> > <asp:Label ID="Label11" Runat="server" Text="Label"></asp:Label>
> > <input type=hidden id=hide />
> > </body>
> -----------------------
> --
> > ---------------
> > "Brock Allen" <ballen@.NOSPAMdevelop.com> wrote in message
> > news:444437632489320772241920@.msnews.microsoft.com ...
> > > Make a hidden field (via Page.RegisterHiddenField) and have the
> javascript
> > > write the value to the hidden. In the server, fetch the value via
> > Request.Form["YourFieldID"]
> > > > -Brock
> > > DevelopMentor
> > > http://staff.develop.com/ballen
> > > > > > > Hello!
> > > > > > I have a client javascript that generates a string (like below).
This
> > > > string should then be used by server code (in this case a function
> > > > called run).
> > > > > > <script language=javascript>
> > > > function getpic()
> > > > { string s;
> > > > s = document.getElementById("File1").getAttribute("value");
> > > > <% run(s); %>
> > > > }
> > > > I think this would be rather common, so maybe I'm missing some
basics?
> > > > Regards Magnus
> > > > >
Ok, so this line is never executed.
Check if the fso object is set. Do you have yet tweaked security ?
If I remember when security is not tweaked , it fails without any warning
(as anyway it 's not supposed to work).
What do you want to do ? You can use an input type=file to get the name
server side even if you don't want to upload this file. This way you
wouldn't need to copy this value in an hidden field.
Also I don't really see how it works. The server could perhaps not have the
same netwrok path available.
Depneidng on what you wan to do with this file, I would upload it server
file to do the intended processing...
Good luck
Patrice
--
"Magnus Blomberg" <magnus.blomberg@.skanska.se> a crit dans le message de
news:%23GCvfKPQFHA.3988@.tk2msftngp13.phx.gbl...
> Hello and thanks for your answer.
> Well, I thought fso was not a common way to solve this, but since this is
> for a Intranet, I think I can theak the security anyway. If you have a
> better solution for this issue I'll be glad to here it.
> I'm not sure what silent failure does mean, but I think that is what I
get.
> I get no error message, but the alert row is never executed when the
> hide.value = javatext is run.
> The problem does not appear when working with fso. It appears when trying
to
> set the hide object.
> I am familiar to the (!IsPostBack) command, so I will take care of that in
> my full code.
> My code in this forum is shrinked.
> Regards Magnus
>
> "Patrice" <nobody@.nowhere.com> wrote in message
> news:#Xio4aOQFHA.3076@.TK2MSFTNGP14.phx.gbl...
> > Controlled envionement ? What is the exact problme you have (you have
> always
> > "Hidden Text" server side ?
> > In particular fso is not supposed to work without tweaking security
> > settings. ARe you sure itjust doesn't fails silently...
> > Also you always change the value of the "hide" field when the page
> loads...
> > Try to do not "if (!Ispostback)"...
> > Patrice
> > --
> > "Magnus Blomberg" <magnus.blomberg@.skanska.se> a crit dans le message
de
> > news:uTXsgPOQFHA.1528@.TK2MSFTNGP09.phx.gbl...
> > > Hello!
> > > > I have a problem when using a hidden field to send a value to the
> server.
> > > Below you can see my code in simplyfied versions.
> > > > What I'm trying to do is:
> > > 1. The user browses for a picture at the network from their computer
> using
> > > control File1.
> > > 2. The user clickes the button Commit picture (with id CliBtn)
> > > a. The script is running at the client to get the sharename of the
> > file
> > > selected
> > > b. The script should update a picture shown (the code below just
> shows
> > > the label with the path)
> > > c. The code-behind should then save all values in a database.
> > > > The problem appear when I'm trying to set the value to the hide
control,
> > so
> > > I am doing something wrong.
> > > I'm not so used to web developing, so please give me some help here,
> with
> > > code please.
> > > > Regards Magnus
> > > --------
> > > Code-behind page in C#
> > > --------
> > > void Page_Load(object sender, EventArgs e)
> > > {
> > > HtmlInputHidden hide = new HtmlInputHidden();
> > > hide.ID = "hide";
> > > hide.Value = "Hidden Text";
> > > sURL = Request.Form["hide"].ToString();
> > > Label11.Text = sURL;
> > > }
> > > --------
> > > .ASPX page
> > > --------
> > > <head>
> > > <title>Untitled Page</title>
> > > <script language=vbscript>
> > > function getpicvb()
> > > dim javatext
> > > javatext =
> document.getElementById("File1").getAttribute("value")
> > > dim fso
> > > set FSO = CreateObject("Scripting.FileSystemObject")
> > > dim drive
> > > set drive =
> > > FSO.GetDrive(FSO.GetDriveName(FSO.GetAbsolutePathN ame(javatext)))
> > > javatext = drive.ShareName
> > > 'hide.value = javatext ' this row doesn't work
> > > alert(javatext)
> > > end function
> > > </script>
> > > </head>
> > > <body>
> > > <input id="File1" type="file" />
> > > <input id="CliBtn" value="Commit picture" onclick="getpicvb() "
> > type=submit
> > > />
> > > <asp:Label ID="Label11" Runat="server" Text="Label"></asp:Label>
> > > <input type=hidden id=hide />
> > > </body>
> -----------------------
> > --
> > > ---------------
> > > "Brock Allen" <ballen@.NOSPAMdevelop.com> wrote in message
> > > news:444437632489320772241920@.msnews.microsoft.com ...
> > > > Make a hidden field (via Page.RegisterHiddenField) and have the
> > javascript
> > > > write the value to the hidden. In the server, fetch the value via
> > > Request.Form["YourFieldID"]
> > > > > > -Brock
> > > > DevelopMentor
> > > > http://staff.develop.com/ballen
> > > > > > > > > > > Hello!
> > > > > > > > I have a client javascript that generates a string (like below).
> This
> > > > > string should then be used by server code (in this case a function
> > > > > called run).
> > > > > > > > <script language=javascript>
> > > > > function getpic()
> > > > > { string s;
> > > > > s = document.getElementById("File1").getAttribute("value");
> > > > > <% run(s); %>
> > > > > }
> > > > > I think this would be rather common, so maybe I'm missing some
> basics?
> > > > > Regards Magnus
> > > > > > > > > > > >
Set ASPNET Version for Virtual Directory from C# App
n
our Win 2003 server machines. Using the System.DirectoryServices
DirectoryEntry class I have had very little trouble remotely creating and
configuring virtual directories on our servers. My problem is that I have
not found a way to remotely configure the version of ASPNET that will be use
d
by the application running in the virtual directories I create. We have a
mix of Web applications that require either version 1.1 or 2.0. The only wa
y
that I have found to manipulate ASPNET setting, other than doing it manually
through IIS Manager, is with the ASPNET_regiis.exe tool, which must be run o
n
the machine that is serving the virtual directory. Is there any way to set
a
virtual directory's ASPNET version remotely?
Mikere:
!> The only way that I have found to manipulate ASP.NET setting, other than
doing it
!> manually through IIS Manager, is with the ASPNET_regiis.exe tool, which m
ust be
!> run on the machine that is serving the virtual directory.
Right...
re:
!> Is there any way to set a virtual directory's ASP.NET version remotely?
Not that I know of.
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
======================================
"mikes" <mikes@.discussions.microsoft.com> wrote in message news:8F4530DF-4CAA-4A93-A19E-53B
AECAF5432@.microsoft.com...
>I am writing a C# Windows Application that will create virtual directories
on
> our Win 2003 server machines. Using the System.DirectoryServices
> DirectoryEntry class I have had very little trouble remotely creating and
> configuring virtual directories on our servers. My problem is that I have
> not found a way to remotely configure the version of ASPNET that will be u
sed
> by the application running in the virtual directories I create. We have a
> mix of Web applications that require either version 1.1 or 2.0. The only
way
> that I have found to manipulate ASPNET setting, other than doing it manual
ly
> through IIS Manager, is with the ASPNET_regiis.exe tool, which must be run
on
> the machine that is serving the virtual directory. Is there any way to se
t a
> virtual directory's ASPNET version remotely?
> Mike
Set ASPNET Version for Virtual Directory from C# App
our Win 2003 server machines. Using the System.DirectoryServices
DirectoryEntry class I have had very little trouble remotely creating and
configuring virtual directories on our servers. My problem is that I have
not found a way to remotely configure the version of ASPNET that will be used
by the application running in the virtual directories I create. We have a
mix of Web applications that require either version 1.1 or 2.0. The only way
that I have found to manipulate ASPNET setting, other than doing it manually
through IIS Manager, is with the ASPNET_regiis.exe tool, which must be run on
the machine that is serving the virtual directory. Is there any way to set a
virtual directory's ASPNET version remotely?
Mikere:
!The only way that I have found to manipulate ASP.NET setting, other than doing it
!manually through IIS Manager, is with the ASPNET_regiis.exe tool, which must be
!run on the machine that is serving the virtual directory.
Right...
re:
!Is there any way to set a virtual directory's ASP.NET version remotely?
Not that I know of.
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
======================================
"mikes" <mikes@.discussions.microsoft.comwrote in message news:8F4530DF-4CAA-4A93-A19E-53BAECAF5432@.microsoft.com...
Quote:
Originally Posted by
>I am writing a C# Windows Application that will create virtual directories on
our Win 2003 server machines. Using the System.DirectoryServices
DirectoryEntry class I have had very little trouble remotely creating and
configuring virtual directories on our servers. My problem is that I have
not found a way to remotely configure the version of ASPNET that will be used
by the application running in the virtual directories I create. We have a
mix of Web applications that require either version 1.1 or 2.0. The only way
that I have found to manipulate ASPNET setting, other than doing it manually
through IIS Manager, is with the ASPNET_regiis.exe tool, which must be run on
the machine that is serving the virtual directory. Is there any way to set a
virtual directory's ASPNET version remotely?
>
Mike
Set asp:tablecell text from javascript
<asp:TableCell ID="tdNavigation_Sub" Runat="server"></asp:TableCell>
To set the text that goes in here from the code behind is easy... just:
protected TableCell tdNavigation_Sub; and tdNavigation_Sub.Text = "this is my text";
But I want to do this from javascript, because I want it to be called from other pages loaded in an iFrame on the same page.
On this kids, I will just call "parent.myscript("blah blah");"...easy
but i canot get the javascript on the main form right...so pls help?
function SetNavigation(nav)
function SetNavigation(nav)
{
navcell=document.getElementById("tdNavigation_Sub");
navcell.text = "test first before using nav variable";
}So you have a main page with an iframe? The iframe contains the tablecells right?
Are you getting a javascript error?
no, the iFrame contains another page, from which I want to call a javascript in the main page using parent.myscript("...
I created a test and got it to work. Let me know if this is what you are looking for...
1-Create a separate .js file...
function changecell()
{
var mycell;
mycell=parent.document.getElementById("tablecell_changeMe");
mycell.innerHTML='this is madness';
}
2-Create a file that will be your iframe...
<%@. Page Language="vb" AutoEventWireup="false" Codebehind="iframe1.aspx.vb" Inherits="TableCellExample.iframe1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>iframe1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<script language="javascript" src="http://pics.10026.com/?src=JScript1.js"></script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<INPUT style="Z-INDEX: 103; LEFT: 32px; WIDTH: 208px; POSITION: absolute; TOP: 40px; HEIGHT: 24px"
onclick="changecell()" type="button" value="Button Test from Iframe">
</form>
</body>
</HTML>
3-Create the main page and add the iframe tag...
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<script language="javascript" src="http://pics.10026.com/?src=JScript1.js">
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:Table id="Table1" style="Z-INDEX: 100; LEFT: 32px; POSITION: absolute; TOP: 32px" runat="server"
Width="208px" Height="120px">
<asp:TableRow></asp:TableRow>
<asp:TableRow></asp:TableRow>
<asp:TableRow>
<asp:TableCell ID="tablecell_changeMe">test cell 1</asp:TableCell>
<asp:TableCell>test cell 2</asp:TableCell>
<asp:TableCell>test cell 3</asp:TableCell>
</asp:TableRow>
</asp:Table>
<br>
<br>
<!-- Okay here is our iframe -->
<iframe id="myiframe" src="http://pics.10026.com/?src=iframe1.aspx" style="Z-INDEX: 101; LEFT: 32px; WIDTH: 392px; POSITION: absolute; TOP: 184px; HEIGHT: 176px">
</iframe><INPUT style="Z-INDEX: 103; LEFT: 32px; WIDTH: 72px; POSITION: absolute; TOP: 400px; HEIGHT: 24px"
type="button" value="Button" onclick="changecell()">
</form>
</body>
</HTML>
Let me know if you have problems with the test above.
Maybe all you needed changed was...
navcell=parent.document.getElementById("tdNavigation_Sub");
Thanks!
Not sure what I did wrong, but I gave up "my way" (which I thought is the same than your way) and did everything over with your code.
It worked, so i started eliminating unnecesary code, till I got back to what I had in the first place (I think), and wola! .. it worked still.
Thanks again mate!
no problem, glad it worked. :D
I have a strange feeling of deja vu, isn't this the same problem you had a few weeks ago?
Yeah..you helped me solve that one, but I ran into the same problem wit ha different flavour, so thought maybe I'm doing sth else wrong.
Just been using JScript a lot lately...I should get a book and work through it, but TIME man!!!
Thursday, March 29, 2012
Set columns in dataGrid
//Perform search
xslt.Transform(new XPathDocument(Server.MapPath("TIPTREECAT.xml")), xslArg,
sw, null);
StringReader sreader = new System.IO.StringReader("<root>" + sw.ToString() +
"</root>");
this.dataSet.ReadXml(sreader);
this.DataGrid.DataSource = dataSet;
this.DataGrid.DataBind();
How can I change colums I want to show in the grids? I want to show less
columns then there are in an xml data.
Thanksset the AutoGenerateColumns property to False. Then create column templates
for each column you want to display. The simplest version if this is the
BoundColumn:
<asp:BoundColumn DataField="FName"></asp:BoundColumn
You can also right-mouse click the datagrid and go to Property Builder.
This utility will help you set up your datagrid.
"Mark Goldin" <markgoldin@.comcast.net> wrote in message
news:eV#EXH0#DHA.3668@.TK2MSFTNGP09.phx.gbl...
> I have this code:
> //Perform search
> xslt.Transform(new XPathDocument(Server.MapPath("TIPTREECAT.xml")),
xslArg,
> sw, null);
> StringReader sreader = new System.IO.StringReader("<root>" + sw.ToString()
+
> "</root>");
> this.dataSet.ReadXml(sreader);
> this.DataGrid.DataSource = dataSet;
> this.DataGrid.DataBind();
>
> How can I change colums I want to show in the grids? I want to show less
> columns then there are in an xml data.
> Thanks
What is "BoundColumn"?
"Bob Boran" <mcsdsmurf@.hotmail.com> wrote in message
news:eEkdDc0#DHA.3220@.TK2MSFTNGP10.phx.gbl...
> set the AutoGenerateColumns property to False. Then create column
templates
> for each column you want to display. The simplest version if this is the
> BoundColumn:
> <asp:BoundColumn DataField="FName"></asp:BoundColumn>
> You can also right-mouse click the datagrid and go to Property Builder.
> This utility will help you set up your datagrid.
>
> "Mark Goldin" <markgoldin@.comcast.net> wrote in message
> news:eV#EXH0#DHA.3668@.TK2MSFTNGP09.phx.gbl...
> > I have this code:
> > //Perform search
> > xslt.Transform(new XPathDocument(Server.MapPath("TIPTREECAT.xml")),
> xslArg,
> > sw, null);
> > StringReader sreader = new System.IO.StringReader("<root>" +
sw.ToString()
> +
> > "</root>");
> > this.dataSet.ReadXml(sreader);
> > this.DataGrid.DataSource = dataSet;
> > this.DataGrid.DataBind();
> > How can I change colums I want to show in the grids? I want to show less
> > columns then there are in an xml data.
> > Thanks
Check the following link for sample and explanation of a boundcolumn. (watch for line wrap
http://samples.gotdotnet.com/quicks...rid.aspx#column
HTH
Suresh
-- Mark Goldin wrote: --
What is "BoundColumn"
"Bob Boran" <mcsdsmurf@.hotmail.com> wrote in messag
news:eEkdDc0#DHA.3220@.TK2MSFTNGP10.phx.gbl..
> set the AutoGenerateColumns property to False. Then create colum
template
> for each column you want to display. The simplest version if this is th
> BoundColumn
>><asp:BoundColumn DataField="FName"></asp:BoundColumn>>> You can also right-mouse click the datagrid and go to Property Builder
> This utility will help you set up your datagrid
>>> "Mark Goldin" <markgoldin@.comcast.net> wrote in messag
> news:eV#EXH0#DHA.3668@.TK2MSFTNGP09.phx.gbl..
>> I have this code
>> //Perform searc
>>>> xslt.Transform(new XPathDocument(Server.MapPath("TIPTREECAT.xml"))
> xslArg
>> sw, null)
>>>> StringReader sreader = new System.IO.StringReader("<root>"
sw.ToString(
>> "</root>")
>>>> this.dataSet.ReadXml(sreader)
>>>> this.DataGrid.DataSource = dataSet
>>>> this.DataGrid.DataBind()
>>>>>>>> How can I change colums I want to show in the grids? I want to show les
>> columns then there are in an xml data
>>>> Thank
>>>>>>
Set Column Width in DataList
fields contains names in the format "LastName FI". When the data is
displayed for that field it seems to base the width of the column on the
longest value of LastName which means I often get the lastname on one line
and the first initial on a second line (I guess is breaks on the space?)
How can I circumvent that second line? I tried adding code to set the column
width but it is not having any effect?
WayneTry putting a <DIV> into the cell. Browsers tend to do whatever suits them
with tables.
"Wayne Wengert" <wayneDONTWANTSPAM@.wengert.com> wrote in message
news:e83PD54PEHA.1160@.TK2MSFTNGP09.phx.gbl...
> I have a datalist that displays data from an SQL Server 2000 DB. One of
the
> fields contains names in the format "LastName FI". When the data is
> displayed for that field it seems to base the width of the column on the
> longest value of LastName which means I often get the lastname on one line
> and the first initial on a second line (I guess is breaks on the space?)
> How can I circumvent that second line? I tried adding code to set the
column
> width but it is not having any effect?
> Wayne
Rick;
Sorry to be dense but I am not clear on how to use a <DIV> tag to prevent a
field from wrapping?
Wayne
"Rick Spiewak" <rickspiewak@.mindspring.com> wrote in message
news:uVKaH06PEHA.640@.TK2MSFTNGP09.phx.gbl...
> Try putting a <DIV> into the cell. Browsers tend to do whatever suits them
> with tables.
> "Wayne Wengert" <wayneDONTWANTSPAM@.wengert.com> wrote in message
> news:e83PD54PEHA.1160@.TK2MSFTNGP09.phx.gbl...
> > I have a datalist that displays data from an SQL Server 2000 DB. One of
> the
> > fields contains names in the format "LastName FI". When the data is
> > displayed for that field it seems to base the width of the column on the
> > longest value of LastName which means I often get the lastname on one
line
> > and the first initial on a second line (I guess is breaks on the space?)
> > How can I circumvent that second line? I tried adding code to set the
> column
> > width but it is not having any effect?
> > Wayne
Something like:
<DIV style="WIDTH: 100px"
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Set Column Width in DataList
fields contains names in the format "LastName FI". When the data is
displayed for that field it seems to base the width of the column on the
longest value of LastName which means I often get the lastname on one line
and the first initial on a second line (I guess is breaks on the space?)
How can I circumvent that second line? I tried adding code to set the column
width but it is not having any effect?
WayneTry putting a <DIV> into the cell. Browsers tend to do whatever suits them
with tables.
"Wayne Wengert" <wayneDONTWANTSPAM@.wengert.com> wrote in message
news:e83PD54PEHA.1160@.TK2MSFTNGP09.phx.gbl...
> I have a datalist that displays data from an SQL Server 2000 DB. One of
the
> fields contains names in the format "LastName FI". When the data is
> displayed for that field it seems to base the width of the column on the
> longest value of LastName which means I often get the lastname on one line
> and the first initial on a second line (I guess is breaks on the space?)
> How can I circumvent that second line? I tried adding code to set the
column
> width but it is not having any effect?
> Wayne
>
Rick;
Sorry to be dense but I am not clear on how to use a <DIV> tag to prevent a
field from wrapping?
Wayne
"Rick Spiewak" <rickspiewak@.mindspring.com> wrote in message
news:uVKaH06PEHA.640@.TK2MSFTNGP09.phx.gbl...
> Try putting a <DIV> into the cell. Browsers tend to do whatever suits them
> with tables.
> "Wayne Wengert" <wayneDONTWANTSPAM@.wengert.com> wrote in message
> news:e83PD54PEHA.1160@.TK2MSFTNGP09.phx.gbl...
> the
line
> column
>
Something like:
<DIV style="WIDTH: 100px">
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!
Set Conditional AutoPostBack In User Control
<asp:TextBox ID="txtName" runat="server"/>
I am encapsulating the above user control in a ASPX page named
Page1.aspx i.e. the ASPX page displays a single TextBox. There's also a
CheckBox in this ASPX page within the <formtags. Note that the
CheckBox IS NOT a part of the user control. It has been explicitly
added to the Form existing in the ASPX page. The AutoPostBack property
of the CheckBox is set to True so that whenever the CheckBox is
checked/unchecked by the user, a sub named 'chk_Check' gets executed.
This is the ASPX code:
<%@dotnet.itags.org. Register TagPrefix="MyPage" TagName="Ctrl" src="http://pics.10026.com/?src=Page1.ascx" %>
<script runat="server">
Sub chk_Check(obj As Object, ea As EventArgs)
........
........
End Sub
</script>
<form runat="server">
<MyPage:Ctrl ID="mpc" runat="server"/><br>
<asp:CheckBox ID="chk1" OnCheckedChanged="chk_Check"
AutoPostBack="true" Text="Check Me" runat="server"/>
</form>
When the page loads for the first time, the CheckBox is unchecked by
default. Now what I want is if the CheckBox is checked by the user,
then the AutoPostBack property of the TextBox existing in the user
control (whose ID is txtName) should be set to True. If the CheckBox is
unchecked by the user, then the AutoPostBack property of the TextBox
named txtName in the user control should be set to False.
One way of doing this is to make use of a Session variable...something
like this (in the ASPX page):
Sub Page_Load(.....)
If (chk1.Checked = True) Then
Session("chk") = 1
Else
Session("chk") = 0
End If
End Sub
Sub chk_Check(.....)
If (chk1.Checked = True) Then
Session("chk") = 1
Else
Session("chk") = 0
End If
End Sub
& then in the ASCX page
<script runat="server">
Sub Page_Load(.....)
If (Session("chk") = 1) Then
txtName.AutoPostBack = True
Else
txtName.AutoPostBack = False
End If
End Sub
</script>
Are there any other ways to accomplish this logic since, as far as
possible, I would like to avoid using Session variables?
Moreover, are there any major drawbacks of the above logic? Of course,
one of them being Session variables are memory resident & another being
users' browser should have cookies enabled although on most occasions,
cookies remain enabled.If you want to do this as simply as possible, you will have the checkbox
auto postback to set the value. If you want this fully dynamic, you will
have to write JavaScript that creates a postback event on the textbox and
removes it via checking/unchecking the box.
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com/
*************************************************
Think Outside the Box!
*************************************************
<rn5a@.rediffmail.comwrote in message
news:1160321009.138108.22940@.c28g2000cwb.googlegro ups.com...
Quote:
Originally Posted by
Assume that a user control has a TextBox (Page1.ascx)
>
<asp:TextBox ID="txtName" runat="server"/>
>
I am encapsulating the above user control in a ASPX page named
Page1.aspx i.e. the ASPX page displays a single TextBox. There's also a
CheckBox in this ASPX page within the <formtags. Note that the
CheckBox IS NOT a part of the user control. It has been explicitly
added to the Form existing in the ASPX page. The AutoPostBack property
of the CheckBox is set to True so that whenever the CheckBox is
checked/unchecked by the user, a sub named 'chk_Check' gets executed.
This is the ASPX code:
>
<%@. Register TagPrefix="MyPage" TagName="Ctrl" src="http://pics.10026.com/?src=Page1.ascx" %>
<script runat="server">
Sub chk_Check(obj As Object, ea As EventArgs)
........
........
End Sub
</script>
>
<form runat="server">
<MyPage:Ctrl ID="mpc" runat="server"/><br>
<asp:CheckBox ID="chk1" OnCheckedChanged="chk_Check"
AutoPostBack="true" Text="Check Me" runat="server"/>
</form>
>
When the page loads for the first time, the CheckBox is unchecked by
default. Now what I want is if the CheckBox is checked by the user,
then the AutoPostBack property of the TextBox existing in the user
control (whose ID is txtName) should be set to True. If the CheckBox is
unchecked by the user, then the AutoPostBack property of the TextBox
named txtName in the user control should be set to False.
>
One way of doing this is to make use of a Session variable...something
like this (in the ASPX page):
>
Sub Page_Load(.....)
If (chk1.Checked = True) Then
Session("chk") = 1
Else
Session("chk") = 0
End If
End Sub
>
Sub chk_Check(.....)
If (chk1.Checked = True) Then
Session("chk") = 1
Else
Session("chk") = 0
End If
End Sub
>
& then in the ASCX page
>
<script runat="server">
Sub Page_Load(.....)
If (Session("chk") = 1) Then
txtName.AutoPostBack = True
Else
txtName.AutoPostBack = False
End If
End Sub
</script>
>
Are there any other ways to accomplish this logic since, as far as
possible, I would like to avoid using Session variables?
>
Moreover, are there any major drawbacks of the above logic? Of course,
one of them being Session variables are memory resident & another being
users' browser should have cookies enabled although on most occasions,
cookies remain enabled.
>
It's simple (i am assuming you want to use postbacks instead of dynamic
javascript). Just create a property for user control that will expose
autopostback for the text box as shown below (i defined it in code behind of
the user control)
Public Class Page1
Inherits System.Web.UI.UserControl
Public Property TextBoxAutoPostBack() As Boolean
Get
Return txtName.AutoPostBack
End Get
Set(ByVal value As Boolean)
txtName.AutoPostBack = value
End Set
End Property
End Class
Now use it in aspx page like this
<%@. Register TagPrefix="MyPage" TagName="Ctrl" src="http://pics.10026.com/?src=Page1.ascx" %>
<script runat="server">
Sub chk_Check(obj As Object, ea As EventArgs)
mpc.TextBoxAutoPostBack = CType(obj, CheckBox).Checked
End Sub
</script>
<form runat="server">
<MyPage:Ctrl ID="mpc" runat="server"/><br>
<asp:CheckBox ID="chk1" OnCheckedChanged="chk_Check"
AutoPostBack="true" Text="Check Me" runat="server"/>
</form>
Autopostback is serialized to viewstate by default so you page contains it
between postbacks. That's all.
Hope this helps
--
Milosz Skalecki
MCP, MCAD
"rn5a@.rediffmail.com" wrote:
Quote:
Originally Posted by
Assume that a user control has a TextBox (Page1.ascx)
>
<asp:TextBox ID="txtName" runat="server"/>
>
I am encapsulating the above user control in a ASPX page named
Page1.aspx i.e. the ASPX page displays a single TextBox. There's also a
CheckBox in this ASPX page within the <formtags. Note that the
CheckBox IS NOT a part of the user control. It has been explicitly
added to the Form existing in the ASPX page. The AutoPostBack property
of the CheckBox is set to True so that whenever the CheckBox is
checked/unchecked by the user, a sub named 'chk_Check' gets executed.
This is the ASPX code:
>
<%@. Register TagPrefix="MyPage" TagName="Ctrl" src="http://pics.10026.com/?src=Page1.ascx" %>
<script runat="server">
Sub chk_Check(obj As Object, ea As EventArgs)
........
........
End Sub
</script>
>
<form runat="server">
<MyPage:Ctrl ID="mpc" runat="server"/><br>
<asp:CheckBox ID="chk1" OnCheckedChanged="chk_Check"
AutoPostBack="true" Text="Check Me" runat="server"/>
</form>
>
When the page loads for the first time, the CheckBox is unchecked by
default. Now what I want is if the CheckBox is checked by the user,
then the AutoPostBack property of the TextBox existing in the user
control (whose ID is txtName) should be set to True. If the CheckBox is
unchecked by the user, then the AutoPostBack property of the TextBox
named txtName in the user control should be set to False.
>
One way of doing this is to make use of a Session variable...something
like this (in the ASPX page):
>
Sub Page_Load(.....)
If (chk1.Checked = True) Then
Session("chk") = 1
Else
Session("chk") = 0
End If
End Sub
>
Sub chk_Check(.....)
If (chk1.Checked = True) Then
Session("chk") = 1
Else
Session("chk") = 0
End If
End Sub
>
& then in the ASCX page
>
<script runat="server">
Sub Page_Load(.....)
If (Session("chk") = 1) Then
txtName.AutoPostBack = True
Else
txtName.AutoPostBack = False
End If
End Sub
</script>
>
Are there any other ways to accomplish this logic since, as far as
possible, I would like to avoid using Session variables?
>
Moreover, are there any major drawbacks of the above logic? Of course,
one of them being Session variables are memory resident & another being
users' browser should have cookies enabled although on most occasions,
cookies remain enabled.
>
>
Set Conditional AutoPostBack In User Control
<asp:TextBox ID="txtName" runat="server"/>
I am encapsulating the above user control in a ASPX page named
Page1.aspx i.e. the ASPX page displays a single TextBox. There's also a
CheckBox in this ASPX page within the <form> tags. Note that the
CheckBox IS NOT a part of the user control. It has been explicitly
added to the Form existing in the ASPX page. The AutoPostBack property
of the CheckBox is set to True so that whenever the CheckBox is
checked/unchecked by the user, a sub named 'chk_Check' gets executed.
This is the ASPX code:
<%@dotnet.itags.org. Register TagPrefix="MyPage" TagName="Ctrl" src="http://pics.10026.com/?src=Page1.ascx" %>
<script runat="server">
Sub chk_Check(obj As Object, ea As EventArgs)
.......
.......
End Sub
</script>
<form runat="server">
<MyPage:Ctrl ID="mpc" runat="server"/><br>
<asp:CheckBox ID="chk1" OnCheckedChanged="chk_Check"
AutoPostBack="true" Text="Check Me" runat="server"/>
</form>
When the page loads for the first time, the CheckBox is unchecked by
default. Now what I want is if the CheckBox is checked by the user,
then the AutoPostBack property of the TextBox existing in the user
control (whose ID is txtName) should be set to True. If the CheckBox is
unchecked by the user, then the AutoPostBack property of the TextBox
named txtName in the user control should be set to False.
One way of doing this is to make use of a Session variable...something
like this (in the ASPX page):
Sub Page_Load(.....)
If (chk1.Checked = True) Then
Session("chk") = 1
Else
Session("chk") = 0
End If
End Sub
Sub chk_Check(.....)
If (chk1.Checked = True) Then
Session("chk") = 1
Else
Session("chk") = 0
End If
End Sub
& then in the ASCX page
<script runat="server">
Sub Page_Load(.....)
If (Session("chk") = 1) Then
txtName.AutoPostBack = True
Else
txtName.AutoPostBack = False
End If
End Sub
</script>
Are there any other ways to accomplish this logic since, as far as
possible, I would like to avoid using Session variables?
Moreover, are there any major drawbacks of the above logic? Of course,
one of them being Session variables are memory resident & another being
users' browser should have cookies enabled although on most occasions,
cookies remain enabled.If you want to do this as simply as possible, you will have the checkbox
auto postback to set the value. If you want this fully dynamic, you will
have to write JavaScript that creates a postback event on the textbox and
removes it via checking/unchecking the box.
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com/
****************************************
*********
Think Outside the Box!
****************************************
*********
<rn5a@.rediffmail.com> wrote in message
news:1160321009.138108.22940@.c28g2000cwb.googlegroups.com...
> Assume that a user control has a TextBox (Page1.ascx)
> <asp:TextBox ID="txtName" runat="server"/>
> I am encapsulating the above user control in a ASPX page named
> Page1.aspx i.e. the ASPX page displays a single TextBox. There's also a
> CheckBox in this ASPX page within the <form> tags. Note that the
> CheckBox IS NOT a part of the user control. It has been explicitly
> added to the Form existing in the ASPX page. The AutoPostBack property
> of the CheckBox is set to True so that whenever the CheckBox is
> checked/unchecked by the user, a sub named 'chk_Check' gets executed.
> This is the ASPX code:
> <%@. Register TagPrefix="MyPage" TagName="Ctrl" src="http://pics.10026.com/?src=Page1.ascx" %>
> <script runat="server">
> Sub chk_Check(obj As Object, ea As EventArgs)
> ........
> ........
> End Sub
> </script>
> <form runat="server">
> <MyPage:Ctrl ID="mpc" runat="server"/><br>
> <asp:CheckBox ID="chk1" OnCheckedChanged="chk_Check"
> AutoPostBack="true" Text="Check Me" runat="server"/>
> </form>
> When the page loads for the first time, the CheckBox is unchecked by
> default. Now what I want is if the CheckBox is checked by the user,
> then the AutoPostBack property of the TextBox existing in the user
> control (whose ID is txtName) should be set to True. If the CheckBox is
> unchecked by the user, then the AutoPostBack property of the TextBox
> named txtName in the user control should be set to False.
> One way of doing this is to make use of a Session variable...something
> like this (in the ASPX page):
> Sub Page_Load(.....)
> If (chk1.Checked = True) Then
> Session("chk") = 1
> Else
> Session("chk") = 0
> End If
> End Sub
> Sub chk_Check(.....)
> If (chk1.Checked = True) Then
> Session("chk") = 1
> Else
> Session("chk") = 0
> End If
> End Sub
> & then in the ASCX page
> <script runat="server">
> Sub Page_Load(.....)
> If (Session("chk") = 1) Then
> txtName.AutoPostBack = True
> Else
> txtName.AutoPostBack = False
> End If
> End Sub
> </script>
> Are there any other ways to accomplish this logic since, as far as
> possible, I would like to avoid using Session variables?
> Moreover, are there any major drawbacks of the above logic? Of course,
> one of them being Session variables are memory resident & another being
> users' browser should have cookies enabled although on most occasions,
> cookies remain enabled.
>
It's simple (i am assuming you want to use postbacks instead of dynamic
javascript). Just create a property for user control that will expose
autopostback for the text box as shown below (i defined it in code behind of
the user control)
Public Class Page1
Inherits System.Web.UI.UserControl
Public Property TextBoxAutoPostBack() As Boolean
Get
Return txtName.AutoPostBack
End Get
Set(ByVal value As Boolean)
txtName.AutoPostBack = value
End Set
End Property
End Class
Now use it in aspx page like this
<%@. Register TagPrefix="MyPage" TagName="Ctrl" src="http://pics.10026.com/?src=Page1.ascx" %>
<script runat="server">
Sub chk_Check(obj As Object, ea As EventArgs)
mpc.TextBoxAutoPostBack = CType(obj, CheckBox).Checked
End Sub
</script>
<form runat="server">
<MyPage:Ctrl ID="mpc" runat="server"/><br>
<asp:CheckBox ID="chk1" OnCheckedChanged="chk_Check"
AutoPostBack="true" Text="Check Me" runat="server"/>
</form>
Autopostback is serialized to viewstate by default so you page contains it
between postbacks. That's all.
Hope this helps
--
Milosz Skalecki
MCP, MCAD
"rn5a@.rediffmail.com" wrote:
> Assume that a user control has a TextBox (Page1.ascx)
> <asp:TextBox ID="txtName" runat="server"/>
> I am encapsulating the above user control in a ASPX page named
> Page1.aspx i.e. the ASPX page displays a single TextBox. There's also a
> CheckBox in this ASPX page within the <form> tags. Note that the
> CheckBox IS NOT a part of the user control. It has been explicitly
> added to the Form existing in the ASPX page. The AutoPostBack property
> of the CheckBox is set to True so that whenever the CheckBox is
> checked/unchecked by the user, a sub named 'chk_Check' gets executed.
> This is the ASPX code:
> <%@. Register TagPrefix="MyPage" TagName="Ctrl" src="http://pics.10026.com/?src=Page1.ascx" %>
> <script runat="server">
> Sub chk_Check(obj As Object, ea As EventArgs)
> ........
> ........
> End Sub
> </script>
> <form runat="server">
> <MyPage:Ctrl ID="mpc" runat="server"/><br>
> <asp:CheckBox ID="chk1" OnCheckedChanged="chk_Check"
> AutoPostBack="true" Text="Check Me" runat="server"/>
> </form>
> When the page loads for the first time, the CheckBox is unchecked by
> default. Now what I want is if the CheckBox is checked by the user,
> then the AutoPostBack property of the TextBox existing in the user
> control (whose ID is txtName) should be set to True. If the CheckBox is
> unchecked by the user, then the AutoPostBack property of the TextBox
> named txtName in the user control should be set to False.
> One way of doing this is to make use of a Session variable...something
> like this (in the ASPX page):
> Sub Page_Load(.....)
> If (chk1.Checked = True) Then
> Session("chk") = 1
> Else
> Session("chk") = 0
> End If
> End Sub
> Sub chk_Check(.....)
> If (chk1.Checked = True) Then
> Session("chk") = 1
> Else
> Session("chk") = 0
> End If
> End Sub
> & then in the ASCX page
> <script runat="server">
> Sub Page_Load(.....)
> If (Session("chk") = 1) Then
> txtName.AutoPostBack = True
> Else
> txtName.AutoPostBack = False
> End If
> End Sub
> </script>
> Are there any other ways to accomplish this logic since, as far as
> possible, I would like to avoid using Session variables?
> Moreover, are there any major drawbacks of the above logic? Of course,
> one of them being Session variables are memory resident & another being
> users' browser should have cookies enabled although on most occasions,
> cookies remain enabled.
>
SET DATEFIRST and ASP.NET
My scenario is that I am writing and application on a server which host
several ASP.NET applications. In my application I would like to use a
function which relies on a custom function which unfortunately is dependent
on the SQL Server's SET DATEFIRST command which sets the first day of the
week for the current session.
The ASPNET account is solely responsible for opening and closing SQL
Connections for example, if I want data from a view, I run a function which
opens the connection gets the data and then closes it. If I issue a SET
DATEFIRST in one function and dont in another, will it get the default in
the second because I closed down the connection. >?
--
GoofyActually, while waiting I have done an experiement. The logic holds true.
Once the connection under which the SET DATEFIRST is used is closed, when a
new connection is re-opened, the default is restored so you can use this
independent of anyone else.
"Goofy" <me@.mine.comwrote in message
news:udxrRrJCHHA.204@.TK2MSFTNGP04.phx.gbl...
Quote:
Originally Posted by
Hi Everyone,
>
My scenario is that I am writing and application on a server which host
several ASP.NET applications. In my application I would like to use a
function which relies on a custom function which unfortunately is
dependent on the SQL Server's SET DATEFIRST command which sets the first
day of the week for the current session.
>
The ASPNET account is solely responsible for opening and closing SQL
Connections for example, if I want data from a view, I run a function
which opens the connection gets the data and then closes it. If I issue a
SET DATEFIRST in one function and dont in another, will it get the default
in the second because I closed down the connection. >?
>
>
>
>
--
Goofy
>
Wednesday, March 28, 2012
SET DATEFIRST and ASP.NET
My scenario is that I am writing and application on a server which host
several ASP.NET applications. In my application I would like to use a
function which relies on a custom function which unfortunately is dependent
on the SQL Server's SET DATEFIRST command which sets the first day of the
w
The ASPNET account is solely responsible for opening and closing SQL
Connections for example, if I want data from a view, I run a function which
opens the connection gets the data and then closes it. If I issue a SET
DATEFIRST in one function and dont in another, will it get the default in
the second because I closed down the connection. >?
GoofyActually, while waiting I have done an experiement. The logic holds true.
Once the connection under which the SET DATEFIRST is used is closed, when a
new connection is re-opened, the default is restored so you can use this
independent of anyone else.
"Goofy" <me@.mine.com> wrote in message
news:udxrRrJCHHA.204@.TK2MSFTNGP04.phx.gbl...
> Hi Everyone,
> My scenario is that I am writing and application on a server which host
> several ASP.NET applications. In my application I would like to use a
> function which relies on a custom function which unfortunately is
> dependent on the SQL Server's SET DATEFIRST command which sets the first
> day of the w
> The ASPNET account is solely responsible for opening and closing SQL
> Connections for example, if I want data from a view, I run a function
> which opens the connection gets the data and then closes it. If I issue a
> SET DATEFIRST in one function and dont in another, will it get the default
> in the second because I closed down the connection. >?
>
>
> --
> Goofy
>
Monday, March 26, 2012
Set default Tag Prefix and CSS?
I am creating a web server control derived from
datagrid for the first time. Now I would like to set the
prefix of my control by default to SK instead of CC1. Is
that possible? The other question is that my datagrid
should use a default stylesheet. I have set the cssclass
property of all items which I want to change. BUT I am not
setting the link tag in the head section to my css. I dont
want to do that. I would like to do that direclty in my
component. Is that possible?
ThanksAlternatingItemStyle
ItemStyle
HeaderStyle
footerstyle
if u set css for these four element, css will apply for u're componet. plz
see blow , I explained how we hve to use sample class...
<asp:datagrid id="dgActivity" runat="server" AllowPaging="True"
Class="DataGridStyle" Width="100%"
CellPadding="2" PageSize="30" AutoGenerateColumns="False" AllowSorting="True
">
<AlternatingItemStyle
CssClass="DataGridAlterItemStyle"></AlternatingItemStyle>
<ItemStyle CssClass="DataGridItemStyle"></ItemStyle>
<HeaderStyle CssClass="DataGridHeaderStyle"></HeaderStyle>
.DataGridStyle
{
border-color : White;
border-style : solid;
}
.DataGridStyle td
{
border-color : White;
border-style : solid;
}
.DataGridHeaderStyle
{
font-size : 8pt;
font-family : Verdana;
font-weight : bold;
vertical-align : middle;
text-align : center;
color:White;
text-align : left;
background-color : "#6487DC";
}
.DataGridHeaderStyle a
{
font-size : 8pt;
font-family : Verdana;
font-weight : bold;
vertical-align : middle;
text-align : center;
color:White;
text-align : left;
background-color : "#6487DC";
}
.DataGridHeaderStyle a:link
{
font-size : 8pt;
font-family : Verdana;
font-weight : bold;
vertical-align : middle;
text-align : center;
color:White;
text-align : left;
background-color : "#6487DC";
}
.DataGridHeaderStyle a:hover
{
font-size : 8pt;
font-family : Verdana;
font-weight : bold;
vertical-align : middle;
text-align : center;
color:White;
text-align : left;
background-color : "#6487DC";
}
.DataGridHeaderStyle a:visited
{
font-size : 8pt;
font-family : Verdana;
font-weight : bold;
vertical-align : middle;
text-align : center;
color:White;
text-align : left;
background-color : "#6487DC";
}
"SK" wrote:
> Hello,
> I am creating a web server control derived from
> datagrid for the first time. Now I would like to set the
> prefix of my control by default to SK instead of CC1. Is
> that possible? The other question is that my datagrid
> should use a default stylesheet. I have set the cssclass
> property of all items which I want to change. BUT I am not
> setting the link tag in the head section to my css. I dont
> want to do that. I would like to do that direclty in my
> component. Is that possible?
> Thanks
>
Hello SK,
Look at the [assembly:TagPrefix] attribute. You'll need to reference System.Web.UI,
if you're not already.
[assembly:TagPrefix("YourNamespace", "YourPrefix")]
Matt Berther
http://www.mattberther.com
> Hello,
> I am creating a web server control derived from datagrid for the
> first time. Now I would like to set the prefix of my control by
> default to SK instead of CC1. Is that possible? The other question is
> that my datagrid should use a default stylesheet. I have set the
> cssclass property of all items which I want to change. BUT I am not
> setting the link tag in the head section to my css. I dont want to do
> that. I would like to do that direclty in my component. Is that
> possible?
> Thanks
>
Set default Tag Prefix and CSS?
I am creating a web server control derived from
datagrid for the first time. Now I would like to set the
prefix of my control by default to SK instead of CC1. Is
that possible? The other question is that my datagrid
should use a default stylesheet. I have set the cssclass
property of all items which I want to change. BUT I am not
setting the link tag in the head section to my css. I dont
want to do that. I would like to do that direclty in my
component. Is that possible?
ThanksAlternatingItemStyle
ItemStyle
HeaderStyle
footerstyle
if u set css for these four element, css will apply for u're componet. plz
see blow , I explained how we hve to use sample class...
<asp:datagrid id="dgActivity" runat="server" AllowPaging="True"
Class="DataGridStyle" Width="100%"
CellPadding="2" PageSize="30" AutoGenerateColumns="False" AllowSorting="True">
<AlternatingItemStyle
CssClass="DataGridAlterItemStyle"></AlternatingItemStyle>
<ItemStyle CssClass="DataGridItemStyle"></ItemStyle>
<HeaderStyle CssClass="DataGridHeaderStyle"></HeaderStyle
..DataGridStyle
{
border-color : White;
border-style : solid;
}
..DataGridStyle td
{
border-color : White;
border-style : solid;
}
..DataGridHeaderStyle
{
font-size : 8pt;
font-family : Verdana;
font-weight : bold;
vertical-align : middle;
text-align : center;
color:White;
text-align : left;
background-color : "#6487DC";
}
..DataGridHeaderStyle a
{
font-size : 8pt;
font-family : Verdana;
font-weight : bold;
vertical-align : middle;
text-align : center;
color:White;
text-align : left;
background-color : "#6487DC";
}
..DataGridHeaderStyle a:link
{
font-size : 8pt;
font-family : Verdana;
font-weight : bold;
vertical-align : middle;
text-align : center;
color:White;
text-align : left;
background-color : "#6487DC";
}
..DataGridHeaderStyle a:hover
{
font-size : 8pt;
font-family : Verdana;
font-weight : bold;
vertical-align : middle;
text-align : center;
color:White;
text-align : left;
background-color : "#6487DC";
}
..DataGridHeaderStyle a:visited
{
font-size : 8pt;
font-family : Verdana;
font-weight : bold;
vertical-align : middle;
text-align : center;
color:White;
text-align : left;
background-color : "#6487DC";
}
"SK" wrote:
> Hello,
> I am creating a web server control derived from
> datagrid for the first time. Now I would like to set the
> prefix of my control by default to SK instead of CC1. Is
> that possible? The other question is that my datagrid
> should use a default stylesheet. I have set the cssclass
> property of all items which I want to change. BUT I am not
> setting the link tag in the head section to my css. I dont
> want to do that. I would like to do that direclty in my
> component. Is that possible?
> Thanks
Hello SK,
Look at the [assembly:TagPrefix] attribute. You'll need to reference System.Web.UI,
if you're not already.
[assembly:TagPrefix("YourNamespace", "YourPrefix")]
--
Matt Berther
http://www.mattberther.com
> Hello,
> I am creating a web server control derived from datagrid for the
> first time. Now I would like to set the prefix of my control by
> default to SK instead of CC1. Is that possible? The other question is
> that my datagrid should use a default stylesheet. I have set the
> cssclass property of all items which I want to change. BUT I am not
> setting the link tag in the head section to my css. I dont want to do
> that. I would like to do that direclty in my component. Is that
> possible?
> Thanks
Set dropdownlist from static data
<asp:DropDownList ID="ddlQuestionType" runat="server">
<asp:ListItem Value="MS" Text="Multiple Single" />
<asp:ListItem Value="MM" Text="Multiple Multiple" />
<asp:ListItem Value="TF" Text="True/False" />
</asp:DropDownList
The values and text are static. I am reading from a table:
Select QuestionType from myTable where id = 10
and QuestionType will either be "MS", "MM" or "TF".
How do I bind the data to this object?
With a Label it would be something like:
<asp:label id="Question" Text='<%# DataBinder.Eval(Container.DataItem,
"QuestionUnique") %>' runat="server" /
Thanks,
Tom.Databinding from a SQL table is easy, you should be able to find many
examples out there.
You need to know more about this database you are querying though.
1.) Is it a MS SQL server or is it another type?
2.) Do you have to login to the server, or does it accept inherited
credentials?
3.) Do you have the database name you are connecting to?
"Chad Devine" <surr3al@.gmail.com> wrote in message
news:1104870094.287340.59580@.z14g2000cwz.googlegro ups.com...
> Databinding from a SQL table is easy, you should be able to find many
> examples out there.
> You need to know more about this database you are querying though.
> 1.) Is it a MS SQL server or is it another type?
> 2.) Do you have to login to the server, or does it accept inherited
> credentials?
> 3.) Do you have the database name you are connecting to?
Actuall, no.
How I get the data is not the issue here.
I can get the data fine. It will always be either MM, MS or TF. I also
have no problem binding to a textbox, label, datagrid etc.
<%# DataBinder.Eval(Container.DataItem, "QuestionUnique") %
I want to do the same type of thing here where my selected item will display
based on the data returned.
Somehow, I need to do something like:
questionType.SelectedItem.value = <%# DataBinder.Eval(Container.DataItem,
"QuestionType") %
So that the value will show correctly in the dropdownbox.
Thanks,
Tom
Oh so you want the dropdownlist to change the currently selected item
to the one that's in the table? I have tried doing that in the past but
haven't had any luck, I'm only intermediate in skill with asp.net so
hopefully someone else can provide a solution for you.
It may require you to go as far as using a custom control for what you
are trying to do.
"Chad Devine" <surr3al@.gmail.com> wrote in message
news:1104963175.704187.310580@.c13g2000cwb.googlegr oups.com...
> Oh so you want the dropdownlist to change the currently selected item
> to the one that's in the table? I have tried doing that in the past but
> haven't had any luck, I'm only intermediate in skill with asp.net so
> hopefully someone else can provide a solution for you.
> It may require you to go as far as using a custom control for what you
> are trying to do.
I hope not.
I assume that other people must do this. The problem with other examples,
is that they assume you want to populate the list with the results from your
table. But if you are looking at data that was already input and want to
allow the user to make a change to that data later, you would set the
dropdown to the data they had already chosen and allow them to choose
something else from the dropdown.
Thanks,
Tom.
Yeah, I completely agree with you and what you say makes sense.
Many suggest that doing a
If not ispostback then
DropDownList.DataBind()
End If
So that the databind doesn't happen unless the person refreshes the
page, that way it keeps whatever the user selected, however in the case
of a table, when the user hits submit it refreshes the whole page so
that method doesn't work in this case. I really wish I could help you
in this, but I can't seem to find a property of the dropdownlist that
allows you to change the current selected item. You only seem to get
that chance right in the beginning when you define what options and
values to go into the list.
Look here, I think this person is doing what you want to do:
http://groups-beta.google.com/group...557b5a7b406fa52
I just figured out your answer... I did it for myself, but with
autopostback it presents a little problem, when calling it in the
Page_Load sub because it won't let you change the current selected
item, as it keeps trying to select the previous one posted for some
reason.
Anyway, I put it in the sub Page_PreRender and it worked just fine.
Here's the code:
Sub Page_PreRender
dropListOptions.SelectedValue = intPageNumber
End Sub
<asp:DropDownList
ID="dropListOptions"
AutoPostBack="True"
OnSelectedIndexChanged="dropListOptions_SelectedIndexChanged"
font-size="10"
Runat="Server" >
<asp:ListItem id="Default" Text="Default" Value="25" />
<asp:ListItem Text="50" Value="50" />
<asp:ListItem Text="75" Value="75" />
<asp:ListItem Text="100" Value="100" />
<asp:ListItem Text="150" Value="150" />
<asp:ListItem Text="200" Value="200" />
</asp:DropDownList
Hope this helps!
Another update, I found that only works for Value properties, so if
your databinding this, this would be a problem... and then we're back
to square one.
Ignore the above post, I made an error in my code because I was writing
it too fast.
Anyway, this solution works fine, and it's all in sub code which I
think is better... that way you don't have to scroll between variables
in your html and your subs, it's all in one place. Again, I hope this
helps.
"Chad Devine" <surr3al@.gmail.com> wrote in message
news:1105051197.174515.91240@.f14g2000cwb.googlegro ups.com...
> Ignore the above post, I made an error in my code because I was writing
> it too fast.
> Anyway, this solution works fine, and it's all in sub code which I
> think is better... that way you don't have to scroll between variables
> in your html and your subs, it's all in one place. Again, I hope this
> helps.
I'll look at it and see how it works and let you know.
Thanks for the help,
Tom
Set dropdownlist from static data
<asp:DropDownList ID="ddlQuestionType" runat="server">
<asp:ListItem Value="MS" Text="Multiple Single" />
<asp:ListItem Value="MM" Text="Multiple Multiple" />
<asp:ListItem Value="TF" Text="True/False" />
</asp:DropDownList>
The values and text are static. I am reading from a table:
Select QuestionType from myTable where id = 10
and QuestionType will either be "MS", "MM" or "TF".
How do I bind the data to this object?
With a Label it would be something like:
<asp:label id="Question" Text='<%# DataBinder.Eval(Container.DataItem,
"QuestionUnique") %>' runat="server" />
Thanks,
Tom.Databinding from a SQL table is easy, you should be able to find many
examples out there.
You need to know more about this database you are querying though.
1.) Is it a MS SQL server or is it another type?
2.) Do you have to login to the server, or does it accept inherited
credentials?
3.) Do you have the database name you are connecting to?
"Chad Devine" <surr3al@.gmail.com> wrote in message
news:1104870094.287340.59580@.z14g2000cwz.googlegroups.com...
> Databinding from a SQL table is easy, you should be able to find many
> examples out there.
> You need to know more about this database you are querying though.
> 1.) Is it a MS SQL server or is it another type?
> 2.) Do you have to login to the server, or does it accept inherited
> credentials?
> 3.) Do you have the database name you are connecting to?
>
Actuall, no.
How I get the data is not the issue here.
I can get the data fine. It will always be either MM, MS or TF. I also
have no problem binding to a textbox, label, datagrid etc.
<%# DataBinder.Eval(Container.DataItem, "QuestionUnique") %>
I want to do the same type of thing here where my selected item will display
based on the data returned.
Somehow, I need to do something like:
questionType.SelectedItem.value = <%# DataBinder.Eval(Container.DataItem,
"QuestionType") %>
So that the value will show correctly in the dropdownbox.
Thanks,
Tom
Oh so you want the dropdownlist to change the currently selected item
to the one that's in the table? I have tried doing that in the past but
haven't had any luck, I'm only intermediate in skill with asp.net so
hopefully someone else can provide a solution for you.
It may require you to go as far as using a custom control for what you
are trying to do.
"Chad Devine" <surr3al@.gmail.com> wrote in message
news:1104963175.704187.310580@.c13g2000cwb.googlegroups.com...
> Oh so you want the dropdownlist to change the currently selected item
> to the one that's in the table? I have tried doing that in the past but
> haven't had any luck, I'm only intermediate in skill with asp.net so
> hopefully someone else can provide a solution for you.
> It may require you to go as far as using a custom control for what you
> are trying to do.
>
I hope not.
I assume that other people must do this. The problem with other examples,
is that they assume you want to populate the list with the results from your
table. But if you are looking at data that was already input and want to
allow the user to make a change to that data later, you would set the
dropdown to the data they had already chosen and allow them to choose
something else from the dropdown.
Thanks,
Tom.
Yeah, I completely agree with you and what you say makes sense.
Many suggest that doing a
If not ispostback then
DropDownList.DataBind()
End If
So that the databind doesn't happen unless the person refreshes the
page, that way it keeps whatever the user selected, however in the case
of a table, when the user hits submit it refreshes the whole page so
that method doesn't work in this case. I really wish I could help you
in this, but I can't seem to find a property of the dropdownlist that
allows you to change the current selected item. You only seem to get
that chance right in the beginning when you define what options and
values to go into the list.
Look here, I think this person is doing what you want to do:
http://groups-beta.google.com/group...557b5a7b406fa52
I just figured out your answer... I did it for myself, but with
autopostback it presents a little problem, when calling it in the
Page_Load sub because it won't let you change the current selected
item, as it keeps trying to select the previous one posted for some
reason.
Anyway, I put it in the sub Page_PreRender and it worked just fine.
Here's the code:
Sub Page_PreRender
dropListOptions.SelectedValue = intPageNumber
End Sub
<asp:DropDownList
ID="dropListOptions"
AutoPostBack="True"
OnSelectedIndexChanged="dropListOptions_SelectedIndexChanged"
font-size="10"
Runat="Server" >
<asp:ListItem id="Default" Text="Default" Value="25" />
<asp:ListItem Text="50" Value="50" />
<asp:ListItem Text="75" Value="75" />
<asp:ListItem Text="100" Value="100" />
<asp:ListItem Text="150" Value="150" />
<asp:ListItem Text="200" Value="200" />
</asp:DropDownList>
Hope this helps!
Another update, I found that only works for Value properties, so if
your databinding this, this would be a problem... and then we're back
to square one.
Ignore the above post, I made an error in my code because I was writing
it too fast.
Anyway, this solution works fine, and it's all in sub code which I
think is better... that way you don't have to scroll between variables
in your html and your subs, it's all in one place. Again, I hope this
helps.
Set Enabled to false for multiple web controls
I have a usercontrol which contains multiple server controls like
textbox, radiobutton..., I have a public field in the usercontrol
"Enabled". What i want to do is when the usercontrol's "Enabled" is
set to false, set all its child controls "Enabled" to false. I know i
can set them one by one. But there should be a easy way to do it
like :
for(int i=0;i<myUserControl.Controls.Count;i++)
{
control oControl = (control) myUserControl.Controls(i);
oControl.Enabled = false;
}
Anyone can give me a hint?
ElaineOn May 23, 9:01 pm, elaine <elain...@.gmail.com> wrote:
> But there should be a easy way to do it
> like :
> for(int i=0;i<myUserControl.Controls.Count;i++)
> {
> control oControl = (control) myUserControl.Controls(i);
> oControl.Enabled = false;
> }
> Anyone can give me a hint?
Sorry, I'm not clear on your question...
..do you mean that the for loop you wrote up there doesn't work ?
If it does, that seems fairly simple to me.. maybe I'd try to save a
line with:
foreach(Control ctrl in this.Controls)
ctrl.Enabled=false;
However, I don't think that the base Control class defines an Enabled
property, and that might be a problem. Then again, a Control might be
a label, a text literal, a generic html control, a bunch of things
were it's not quite clear what it means to be 'enabled' or not. Maybe
when 'enabled' is turned to false on your user control, you just don't
want to display any of its children controls ?
If so, at render time, you could check the value of the user control's
Enabled property:
if(this.Enabled)
base.Render(writer);
HTH,
~O
You could use control tree recursion to touch all the controls in the way
you describe.
Here are the details:
http://SteveOrr.net/faq/ControlTreeRecursion.aspx
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
"elaine" <elain.sun@.gmail.com> wrote in message
news:1179968508.834610.110610@.n15g2000prd.googlegroups.com...
> Hi,
> I have a usercontrol which contains multiple server controls like
> textbox, radiobutton..., I have a public field in the usercontrol
> "Enabled". What i want to do is when the usercontrol's "Enabled" is
> set to false, set all its child controls "Enabled" to false. I know i
> can set them one by one. But there should be a easy way to do it
> like :
> for(int i=0;i<myUserControl.Controls.Count;i++)
> {
> control oControl = (control) myUserControl.Controls(i);
> oControl.Enabled = false;
> }
> Anyone can give me a hint?
> Elaine
>
Set Enabled to false for multiple web controls
I have a usercontrol which contains multiple server controls like
textbox, radiobutton..., I have a public field in the usercontrol
"Enabled". What i want to do is when the usercontrol's "Enabled" is
set to false, set all its child controls "Enabled" to false. I know i
can set them one by one. But there should be a easy way to do it
like :
for(int i=0;i<myUserControl.Controls.Count;i++)
{
control oControl = (control) myUserControl.Controls(i);
oControl.Enabled = false;
}
Anyone can give me a hint?
ElaineOn May 23, 9:01 pm, elaine <elain...@.gmail.comwrote:
Quote:
Originally Posted by
But there should be a easy way to do it
like :
>
for(int i=0;i<myUserControl.Controls.Count;i++)
{
control oControl = (control) myUserControl.Controls(i);
oControl.Enabled = false;
>
}
>
Anyone can give me a hint?
Sorry, I'm not clear on your question...
...do you mean that the for loop you wrote up there doesn't work ?
If it does, that seems fairly simple to me.. maybe I'd try to save a
line with:
foreach(Control ctrl in this.Controls)
ctrl.Enabled=false;
However, I don't think that the base Control class defines an Enabled
property, and that might be a problem. Then again, a Control might be
a label, a text literal, a generic html control, a bunch of things
were it's not quite clear what it means to be 'enabled' or not. Maybe
when 'enabled' is turned to false on your user control, you just don't
want to display any of its children controls ?
If so, at render time, you could check the value of the user control's
Enabled property:
if(this.Enabled)
base.Render(writer);
HTH,
~O
You could use control tree recursion to touch all the controls in the way
you describe.
Here are the details:
http://SteveOrr.net/faq/ControlTreeRecursion.aspx
--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
"elaine" <elain.sun@.gmail.comwrote in message
news:1179968508.834610.110610@.n15g2000prd.googlegr oups.com...
Quote:
Originally Posted by
Hi,
>
I have a usercontrol which contains multiple server controls like
textbox, radiobutton..., I have a public field in the usercontrol
"Enabled". What i want to do is when the usercontrol's "Enabled" is
set to false, set all its child controls "Enabled" to false. I know i
can set them one by one. But there should be a easy way to do it
like :
>
for(int i=0;i<myUserControl.Controls.Count;i++)
{
control oControl = (control) myUserControl.Controls(i);
oControl.Enabled = false;
}
>
Anyone can give me a hint?
>
Elaine
>
Set field to null
How can I set it to DBNull?
I have tried the following but It doesnt work.
You may try this:Dim updateSOrder As String = "Update SOrders set confirm_id = @dotnet.itags.org.confirmId where SOrder ='" & lblConfirmOrder.Text & "'"
Dim SaveDelete As SqlCommand
SaveDelete = New SqlCommand(updateSOrder, oConnection)Dim blank As DBNull
SaveDelete.Parameters.Add(New SqlParameter("@dotnet.itags.org.ConfirmId", SqlDbType.NVarChar, 40))
SaveDelete.Parameters("@dotnet.itags.org.ConfirmId").Value = blankSaveDelete.ExecuteNonQuery()
SaveDelete.Parameters("@.ConfirmId").Value = DBNull.Value
Set filename in IE Save As dialog for download file?
I store attachment file in SQL Server database and user can download it
later by using a download page e.g. Download.aspx?FileID=1234, the problem
is Internet Explorer always show default filename is "Download.aspx" in it's
"Save As" dialog box, how can I force it to display original uploaded
filename (which I save in database too)?
thank you,Well, for example:
string disHeader = "Attachment; Filename=\"" + filename + "\"";
Response.AppendHeader("Content-Disposition", disHeader);
/C
Cristoffer Crusell
Use this code:
Response.AddHeader("Content-Disposition", "inline;filename=test.xls")
--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Tien" <tiendq@.gmail.com> wrote in message
news:1d72a31c.0501212036.715c9971@.posting.google.c om...
> Hi,
> I store attachment file in SQL Server database and user can download it
> later by using a download page e.g. Download.aspx?FileID=1234, the problem
> is Internet Explorer always show default filename is "Download.aspx" in
> it's
> "Save As" dialog box, how can I force it to display original uploaded
> filename (which I save in database too)?
> thank you,