Saturday, March 31, 2012
Server Side Controls in ASP.NET
I have an aspx page with some server side textboxes.
I have a button onmy page which allows users to add data
to a database.
In my onclick event for my button when I try and get teh
value from the textbox using..
Dim myString as String = textbox1.text
...it is blank.
When I do a..
Dim myString = Request.Form("textbox1")
...I get the value the user enetered.
I have declared my textbox as a control in my codebehind.
And it is an asp.net textbox.
Any ideas why this is?
This is baffling me.
Kerri.Have you added the "runat=server" attribute to the template HTML for the
text box?
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.
"Kerri" <anonymous@.discussions.microsoft.com> wrote in message
news:017401c39cc4$12c55070$a501280a@.phx.gbl...
> Hi,
> I have an aspx page with some server side textboxes.
> I have a button onmy page which allows users to add data
> to a database.
> In my onclick event for my button when I try and get teh
> value from the textbox using..
> Dim myString as String = textbox1.text
> ..it is blank.
> When I do a..
> Dim myString = Request.Form("textbox1")
> ..I get the value the user enetered.
> I have declared my textbox as a control in my codebehind.
> And it is an asp.net textbox.
> Any ideas why this is?
> This is baffling me.
> Kerri.
server side javascript array
script will eventually have parts being loaded from a database... this is
just a first step to get there... Here is the code
Dim mScript As New System.Text.StringBuilder
mScript = mScript.Append("<script type='text/javascript'>" & vbNewLine)
mScript.Append("var mIconAry = new Array();" & vbNewLine)
mScript.Append("mIconAry[" & 0 & "]='" &
"http://maps.google.com/mapfiles/ms/icons/purple-pushpin.png" & "';" &
vbNewLine)
mScript.Append("mIconAry[" & 1 & "]='" &
"http://maps.google.com/mapfiles/ms/icons/green-pushpin.png" & "';" &
vbNewLine)
'mScript.Append("var mInfoBox = new Array();" & vbNewLine)
'mscript.Append("mInfoBox[" & 0 & "]='" &
mScript.Append("</script>")
RegisterStartupScript("RegisterClientScriptBlock", mScript.ToString())
when i run this.. the javascript isn't there. I've tried looking using
firefox and a plugin that allows you to see all the javascript and it's not
there.. i'm using the same technique as i've used on another page and it
works there.. i don't think i've left anything out.
I'd like to use this array to put pushpins onto a microsoft virutal earth
map that i'm using. anyway.. anyone have any idea's what i'm doing wrong
in my code above.
thanks
shannonWhy don't you use the RegisterArrayDeclaration method?
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"jvcoach23" <shannonr@.sucss.state.il.us> wrote in message
news:1383ly3ijx2rg$.s770m2o8r3kg$.dlg@.40tude.net...
>I am trying to load an array on the load of a page to javascript. the
> script will eventually have parts being loaded from a database... this is
> just a first step to get there... Here is the code
> Dim mScript As New System.Text.StringBuilder
> mScript = mScript.Append("<script type='text/javascript'>" & vbNewLine)
> mScript.Append("var mIconAry = new Array();" & vbNewLine)
> mScript.Append("mIconAry[" & 0 & "]='" &
> "http://maps.google.com/mapfiles/ms/icons/purple-pushpin.png" & "';" &
> vbNewLine)
> mScript.Append("mIconAry[" & 1 & "]='" &
> "http://maps.google.com/mapfiles/ms/icons/green-pushpin.png" & "';" &
> vbNewLine)
> 'mScript.Append("var mInfoBox = new Array();" & vbNewLine)
> 'mscript.Append("mInfoBox[" & 0 & "]='" &
> mScript.Append("</script>")
> RegisterStartupScript("RegisterClientScriptBlock", mScript.ToString())
> when i run this.. the javascript isn't there. I've tried looking using
> firefox and a plugin that allows you to see all the javascript and it's
> not
> there.. i'm using the same technique as i've used on another page and it
> works there.. i don't think i've left anything out.
> I'd like to use this array to put pushpins onto a microsoft virutal earth
> map that i'm using. anyway.. anyone have any idea's what i'm doing wrong
> in my code above.
> thanks
> shannon
Thanks
in doing a little searching... i see this
RegisterArrayDeclaration("TextBoxes","TextBox1")
RegisterArrayDeclaration("TextBoxes", "TextBox2")
and they say that it will produce
<script language="javascript" >
<!--
var TextBoxes = new Array(TextBox1, TextBox2);
// -->
</script>
is it as simple as that to get the array in there... i've tried it.. the
array is not showing up in the javascript.. so i'm just curious if what
i've read is incorrect.
thanks
I added the ClientScript.RegisterArrayDeclaration("mIconAry",
"http://maps.google.com/mapfiles/ms/icons/purple-pushpin.png")
to another page.. and when the page renders.. it puts the array in
var mIconAry = new
Array(http://maps.google.com/mapfiles/ms/...ple-pushpin.png);
but when i try it on a different page, within the same project... on the
page with the microsoft map... it doesn't show up...
hope that is helpful
shannon
the non-woprking page probably does a redirect, so none of its html is of an
y
use.
-- bruce (sqlwork.com)
"jvcoach23" wrote:
> I added the ClientScript.RegisterArrayDeclaration("mIconAry",
> "http://maps.google.com/mapfiles/ms/icons/purple-pushpin.png")
> to another page.. and when the page renders.. it puts the array in
> var mIconAry = new
> Array(http://maps.google.com/mapfiles/ms/...ple-pushpin.png);
> but when i try it on a different page, within the same project... on the
> page with the microsoft map... it doesn't show up...
> hope that is helpful
> shannon
>
Found the problem... the line needed to read
ClientScript.RegisterArrayDeclaration("mIconAry",
"'http://maps.google.com/mapfiles/ms/icons/purple-pushpin.png'")
I needed the single ' inside of the double "
thanks
shannon
Monday, March 26, 2012
Server Time
Can anyone please tell me how I can get the date and time of the Server (eg
Server where SQL Database resides) to display on the ASP.NET page?.
Thanks
LH"lhak" <hak1lin@.swiftdsl.com.au> wrote in message
news:uqVuzTesEHA.2548@.TK2MSFTNGP11.phx.gbl...
> Can anyone please tell me how I can get the date and time of the Server
> (eg
> Server where SQL Database resides) to display on the ASP.NET page?.
Dead easy in the case of SQL Server because you can just read "SELECT
getdate()" into an SqlDataReader
Server Time
Can anyone please tell me how I can get the date and time of the Server (eg
Server where SQL Database resides) to display on the ASP.NET page?.
Thanks
LH"lhak" <hak1lin@.swiftdsl.com.au> wrote in message
news:uqVuzTesEHA.2548@.TK2MSFTNGP11.phx.gbl...
> Can anyone please tell me how I can get the date and time of the Server
> (eg
> Server where SQL Database resides) to display on the ASP.NET page?.
Dead easy in the case of SQL Server because you can just read "SELECT
getdate()" into an SqlDataReader
Saturday, March 24, 2012
Server Unavailable message
locally and has a user that has a local Access database that launches the ap
p
from a URL. They are receiveing the following error:
Server Application Unavailable
The web application you are attempting to access on this web server is
currently unavailable. Please hit the "Refresh" button in your web browser
to retry your request.
Administrator Note: An error message detailing the cause of this specific
request failure can be found in the application event log of the web server.
Please review this log entry to discover what caused this error to occur.What does the error logged to the
Application Event Log say ?
Juan T. Llibre
ASP.NET MVP
===========
"Steven Babb" <StevenBabb@.discussions.microsoft.com> wrote in message
news:1D03B110-B0C9-4A8F-AEC3-FCA9F5A24879@.microsoft.com...
>I have taken over responsibilities for a .NET app that runs on IIS Server
> locally and has a user that has a local Access database that launches the
> app
> from a URL. They are receiveing the following error:
> Server Application Unavailable
> The web application you are attempting to access on this web server is
> currently unavailable. Please hit the "Refresh" button in your web
> browser
> to retry your request.
> Administrator Note: An error message detailing the cause of this specific
> request failure can be found in the application event log of the web
> server.
> Please review this log entry to discover what caused this error to occur.
>
Server Unavailable message
locally and has a user that has a local Access database that launches the app
from a URL. They are receiveing the following error:
Server Application Unavailable
The web application you are attempting to access on this web server is
currently unavailable. Please hit the "Refresh" button in your web browser
to retry your request.
Administrator Note: An error message detailing the cause of this specific
request failure can be found in the application event log of the web server.
Please review this log entry to discover what caused this error to occur.What does the error logged to the
Application Event Log say ?
Juan T. Llibre
ASP.NET MVP
===========
"Steven Babb" <StevenBabb@.discussions.microsoft.com> wrote in message
news:1D03B110-B0C9-4A8F-AEC3-FCA9F5A24879@.microsoft.com...
>I have taken over responsibilities for a .NET app that runs on IIS Server
> locally and has a user that has a local Access database that launches the
> app
> from a URL. They are receiveing the following error:
> Server Application Unavailable
> The web application you are attempting to access on this web server is
> currently unavailable. Please hit the "Refresh" button in your web
> browser
> to retry your request.
> Administrator Note: An error message detailing the cause of this specific
> request failure can be found in the application event log of the web
> server.
> Please review this log entry to discover what caused this error to occur.
server updateing data already on the client
I would like that when data is updated in a database on
the sever taht all instance of that data already being
viewed on aspx pages by clients be updated. Is this
acheiveble with an activeX control on the page that
listens for information from the server? I dont want to
have to use page refreshes firing in a loop.
Thanks in advance
JakeYou can write a Windows Form application and host it in a browser, just like
ActiveX. You'll need to use remoting for that though.
The catch is that every user must have IE and .NET framework installed.
Other browsers don't support .NET "applets"
"Jake" <anonymous@.discussions.microsoft.com> wrote in message
news:2418501c45f00$7f8a8640$a501280a@.phx.gbl...
> Hi
> I would like that when data is updated in a database on
> the sever taht all instance of that data already being
> viewed on aspx pages by clients be updated. Is this
> acheiveble with an activeX control on the page that
> listens for information from the server? I dont want to
> have to use page refreshes firing in a loop.
> Thanks in advance
> Jake
Thanks that sounds exactly like what I am after.
Would you know of where I can find information about
imbeding/running windows application in a web page/
browser and remoting?
Thanks again
Jake
>--Original Message--
>You can write a Windows Form application and host it in
a browser, just like
>ActiveX. You'll need to use remoting for that though.
>The catch is that every user must have IE and .NET
framework installed.
>Other browsers don't support .NET "applets"
>"Jake" <anonymous@.discussions.microsoft.com> wrote in
message
>news:2418501c45f00$7f8a8640$a501280a@.phx.gbl...
>> Hi
>>
>> I would like that when data is updated in a database on
>> the sever taht all instance of that data already being
>> viewed on aspx pages by clients be updated. Is this
>> acheiveble with an activeX control on the page that
>> listens for information from the server? I dont want
to
>> have to use page refreshes firing in a loop.
>>
>> Thanks in advance
>>
>> Jake
>
>.
server updateing data already on the client
I would like that when data is updated in a database on
the sever taht all instance of that data already being
viewed on aspx pages by clients be updated. Is this
acheiveble with an activeX control on the page that
listens for information from the server? I dont want to
have to use page refreshes firing in a loop.
Thanks in advance
JakeYou can write a Windows Form application and host it in a browser, just like
ActiveX. You'll need to use remoting for that though.
The catch is that every user must have IE and .NET framework installed.
Other browsers don't support .NET "applets"
"Jake" <anonymous@.discussions.microsoft.com> wrote in message
news:2418501c45f00$7f8a8640$a501280a@.phx
.gbl...
> Hi
> I would like that when data is updated in a database on
> the sever taht all instance of that data already being
> viewed on aspx pages by clients be updated. Is this
> acheiveble with an activeX control on the page that
> listens for information from the server? I dont want to
> have to use page refreshes firing in a loop.
> Thanks in advance
> Jake
Thanks that sounds exactly like what I am after.
Would you know of where I can find information about
imbeding/running windows application in a web page/
browser and remoting?
Thanks again
Jake
>--Original Message--
>You can write a Windows Form application and host it in
a browser, just like
>ActiveX. You'll need to use remoting for that though.
>The catch is that every user must have IE and .NET
framework installed.
>Other browsers don't support .NET "applets"
>"Jake" <anonymous@.discussions.microsoft.com> wrote in
message
> news:2418501c45f00$7f8a8640$a501280a@.phx
.gbl...
to
>
>.
>
Tuesday, March 13, 2012
Server.MapPath
Webhost provideer. When I set up my FTP account, it indicated that my
physical path was "E:\www.MyWebsite.com".
When I asked my webhost if I could use this as my physical address, they
indicated that I should create a directory under the root and place my
access database there and the use the "Server.MetPath(string)" to retrieve
the path.
My question is what value do I place in the "String" portion of the method.
I am guessing that I would put "www.MyWebsite.com/MyDataFolder". Is that
correct?
If that is correct, then how will I be able to modify my code to work on my
test machine and work on the production box without changes? I would guess
that I would use "localhost" or my IP address, but that would not be the
same for when I move the code to the production box. I guess I could place
the value in the web.config file, but is there a better way to do this?
Thanks in advance for your assistance!!!!!!!!!!!!Hi Jim,
You will need to use Server.MapPath not Server.MetPath
In your website say http://www.MyWebsite.com/MyDataFolder
,MyDataFolder is the virtual path.
To translate this virtual path into the actual physical path you need to use
Server.MapPath.
It will be like : Server.MapPath("MyDataFolder") which will give you
the physical path.
The output of this will be like E:\www.MyWebsite.com\MyDataFolder which is
the actual physical path.
Hope this helps.
Regards,
Marshal Antony
..NET Developer
http://www.dotnetmarshal.com
"Jim Heavey" <JimHeavey@.nospam.com> wrote in message
news:Xns9498E011611CBJimHeaveyhotmailcom@.207.46.24 8.16...
> I am trying to set up the "path" for were my Access Database is on my
> Webhost provideer. When I set up my FTP account, it indicated that my
> physical path was "E:\www.MyWebsite.com".
> When I asked my webhost if I could use this as my physical address, they
> indicated that I should create a directory under the root and place my
> access database there and the use the "Server.MetPath(string)" to retrieve
> the path.
> My question is what value do I place in the "String" portion of the
method.
> I am guessing that I would put "www.MyWebsite.com/MyDataFolder". Is that
> correct?
> If that is correct, then how will I be able to modify my code to work on
my
> test machine and work on the production box without changes? I would
guess
> that I would use "localhost" or my IP address, but that would not be the
> same for when I move the code to the production box. I guess I could
place
> the value in the web.config file, but is there a better way to do this?
> Thanks in advance for your assistance!!!!!!!!!!!!
You probably just want Server.MapPath("/MyDataFolder"). Since the string
doesn't contain the host name, there is no need to change it for your test
server.
"Jim Heavey" <JimHeavey@.nospam.com> wrote in message
news:Xns9498E011611CBJimHeaveyhotmailcom@.207.46.24 8.16...
> I am trying to set up the "path" for were my Access Database is on my
> Webhost provideer. When I set up my FTP account, it indicated that my
> physical path was "E:\www.MyWebsite.com".
> When I asked my webhost if I could use this as my physical address, they
> indicated that I should create a directory under the root and place my
> access database there and the use the "Server.MetPath(string)" to retrieve
> the path.
> My question is what value do I place in the "String" portion of the
method.
> I am guessing that I would put "www.MyWebsite.com/MyDataFolder". Is that
> correct?
> If that is correct, then how will I be able to modify my code to work on
my
> test machine and work on the production box without changes? I would
guess
> that I would use "localhost" or my IP address, but that would not be the
> same for when I move the code to the production box. I guess I could
place
> the value in the web.config file, but is there a better way to do this?
> Thanks in advance for your assistance!!!!!!!!!!!!
Server.MapPath in Global.asax
in an application variable the path of my database. Global.asax is in the
root directory of my web folder and database is in database/database.mdb.
Now, if I start my web site from default.aspx in the root folder all is ok,
but if start it with a page in a nested folder Global.asax can't find the
folder because Server.MapPath use the relative path of nested folder as base
for its search.
What can I do?
Many thanks
SebastianoUse an absolute path for the Server.MapPath argument such as
~/database/database.mdb instead of just database/database.mdb
Patrice
"Sebastiano" <info@.sebastianogazzola.it> a crit dans le message de
news:OtVprw4IEHA.3964@.TK2MSFTNGP10.phx.gbl...
> I want to use Server.MapPath function in Global.asax because I want to
save
> in an application variable the path of my database. Global.asax is in the
> root directory of my web folder and database is in database/database.mdb.
> Now, if I start my web site from default.aspx in the root folder all is
ok,
> but if start it with a page in a nested folder Global.asax can't find the
> folder because Server.MapPath use the relative path of nested folder as
base
> for its search.
> What can I do?
> Many thanks
> Sebastiano
>
try to use Request.PhysicalApplicationPath to combine path
Thanks.
Lostinet (MS ASP.NET MVP)
lostinetweb@.hotmail.com
--
Need MessageBox,ComboBox,DatePicker,PasswordB
ox,TreeView,ASP.Net RPC ?
http://www.lostinet.com/
"Sebastiano" <info@.sebastianogazzola.it> д?
news:OtVprw4IEHA.3964@.TK2MSFTNGP10.phx.gbl...
> I want to use Server.MapPath function in Global.asax because I want to
save
> in an application variable the path of my database. Global.asax is in the
> root directory of my web folder and database is in database/database.mdb.
> Now, if I start my web site from default.aspx in the root folder all is
ok,
> but if start it with a page in a nested folder Global.asax can't find the
> folder because Server.MapPath use the relative path of nested folder as
base
> for its search.
> What can I do?
> Many thanks
> Sebastiano
>
Thank you so much, I can't understand why MS did not mention the importance
of the "~" symbol in the path request. I have waisted hours trying to look
for documentation.
- Rashad
"Patrice" <nobody@.nowhere.com> wrote in message
news:upo4Do6IEHA.3964@.TK2MSFTNGP10.phx.gbl...
> Use an absolute path for the Server.MapPath argument such as
> ~/database/database.mdb instead of just database/database.mdb
> Patrice
> "Sebastiano" <info@.sebastianogazzola.it> a crit dans le message de
> news:OtVprw4IEHA.3964@.TK2MSFTNGP10.phx.gbl...
> save
the
database/database.mdb.
> ok,
the
> base
>
Server.MapPath in Global.asax
in an application variable the path of my database. Global.asax is in the
root directory of my web folder and database is in database/database.mdb.
Now, if I start my web site from default.aspx in the root folder all is ok,
but if start it with a page in a nested folder Global.asax can't find the
folder because Server.MapPath use the relative path of nested folder as base
for its search.
What can I do?
Many thanks
SebastianoUse an absolute path for the Server.MapPath argument such as
~/database/database.mdb instead of just database/database.mdb
Patrice
"Sebastiano" <info@.sebastianogazzola.it> a crit dans le message de
news:OtVprw4IEHA.3964@.TK2MSFTNGP10.phx.gbl...
> I want to use Server.MapPath function in Global.asax because I want to
save
> in an application variable the path of my database. Global.asax is in the
> root directory of my web folder and database is in database/database.mdb.
> Now, if I start my web site from default.aspx in the root folder all is
ok,
> but if start it with a page in a nested folder Global.asax can't find the
> folder because Server.MapPath use the relative path of nested folder as
base
> for its search.
> What can I do?
> Many thanks
> Sebastiano
try to use Request.PhysicalApplicationPath to combine path
--
Thanks.
Lostinet (MS ASP.NET MVP)
lostinetweb@.hotmail.com
--------
Need MessageBox,ComboBox,DatePicker,PasswordBox,TreeVie w,ASP.Net RPC ?
http://www.lostinet.com/
"Sebastiano" <info@.sebastianogazzola.it> д?
news:OtVprw4IEHA.3964@.TK2MSFTNGP10.phx.gbl...
> I want to use Server.MapPath function in Global.asax because I want to
save
> in an application variable the path of my database. Global.asax is in the
> root directory of my web folder and database is in database/database.mdb.
> Now, if I start my web site from default.aspx in the root folder all is
ok,
> but if start it with a page in a nested folder Global.asax can't find the
> folder because Server.MapPath use the relative path of nested folder as
base
> for its search.
> What can I do?
> Many thanks
> Sebastiano
Thank you so much, I can't understand why MS did not mention the importance
of the "~" symbol in the path request. I have waisted hours trying to look
for documentation.
- Rashad
"Patrice" <nobody@.nowhere.com> wrote in message
news:upo4Do6IEHA.3964@.TK2MSFTNGP10.phx.gbl...
> Use an absolute path for the Server.MapPath argument such as
> ~/database/database.mdb instead of just database/database.mdb
> Patrice
> "Sebastiano" <info@.sebastianogazzola.it> a crit dans le message de
> news:OtVprw4IEHA.3964@.TK2MSFTNGP10.phx.gbl...
> > I want to use Server.MapPath function in Global.asax because I want to
> save
> > in an application variable the path of my database. Global.asax is in
the
> > root directory of my web folder and database is in
database/database.mdb.
> > Now, if I start my web site from default.aspx in the root folder all is
> ok,
> > but if start it with a page in a nested folder Global.asax can't find
the
> > folder because Server.MapPath use the relative path of nested folder as
> base
> > for its search.
> > What can I do?
> > Many thanks
> > Sebastiano