Showing posts with label across. Show all posts
Showing posts with label across. Show all posts

Thursday, March 29, 2012

Server Side Set Focux

I've been researching on how to set focus to a WebControl, and the only results I'm coming across are using JavaScript. I was curious if there was a way to code this on the serverside codebehind (I am using VB) file.
The reason I ask is because I have two DropDownLists, when one is changed, the second is populated from a database based off of what the first one's value is. In the OnSelectedIndexChange event I have set up already, it would be really easy to put at the bottom of this method a DropDownList.setFocus(), but I don't seem to find that method available to the DropDownLists.
Is this is a feature that hasn't been implemented yet, or is there not a way to do this currently in the code behind and only with JavaScript?

DSimmonRemember that your web form is generating HTML and sometimes javascript to the browser to tell it what to show. HTML doesn't have a focus concept. So you are left with javascript. It is easy to set focus by writing code on the server side that generates the precise javascript.

Page.RegisterStartupScript("focus", "<script language='javascript'>document.all['" + DropDownList1.ClientID + "'].setFocus();</script>)
Here is a good solutionview post 821121

regards

Server side viewstate

In looking for a way to trim down viewstate, I came across the
following articles to store viewstate in session:

http://aspalliance.com/72
http://msdn.microsoft.com/library/d...ml/PgStPrst.asp
It appears as if the first link is actually better as it allows for a
"history" of viewstates to be availabale.

Anyone have experience using either one of these methods?

Thanks."emde" <emdeusenet@.yahoo.comwrote in message
news:1161638474.044477.141050@.b28g2000cwb.googlegr oups.com...

Quote:

Originally Posted by

In looking for a way to trim down viewstate, I came across the
following articles to store viewstate in session:
>
http://aspalliance.com/72
>
http://msdn.microsoft.com/library/d...ml/PgStPrst.asp
>
>
It appears as if the first link is actually better as it allows for a
"history" of viewstates to be availabale.
>
Anyone have experience using either one of these methods?


ViewState, as with hundreds of other features of ASP.NET, is extremely
useful when it's extremely useful.

But let's not get too carried away here - ViewState *does* add a bit of
overhead to every page which uses it, but unless the page is huge with loads
and loads of WebControls and HTMLControls, it's probably not going to make
that much of a difference to most users. It's just text after all. The page
may take a second or so longer to load, but that's about it...

If the page is huge with loads and loads of WebControls and HTMLControls,
then it's been badly designed in the first place, so ViewState really is the
least of your worries...:-)

There are loads and loads of ways to improve the performance of ASP.NET
sites, but ViewState is IMO opinion fairly far down the list.

By all means be aware that it's always a "good thing" to minimise the amount
of traffic between server and client and back again, so set
EnableViewState="false" for all those controls which don't need it - but
it's really not necessary to devote any more time to it than that...
Mark Rae wrote:

Quote:

Originally Posted by

There are loads and loads of ways to improve the performance of ASP.NET
sites, but ViewState is IMO opinion fairly far down the list.
>...
By all means be aware that it's always a "good thing" to minimise the amount
of traffic between server and client and back again, so set
EnableViewState="false" for all those controls which don't need it - but
it's really not necessary to devote any more time to it than that...


While I agree with you, I am working with the wizard control and
viewstate gets out of hand really quick :)
"emde" <emdeusenet@.yahoo.comwrote in message
news:1161639998.986367.317610@.e3g2000cwe.googlegro ups.com...

Quote:

Originally Posted by

Mark Rae wrote:
>

Quote:

Originally Posted by

>There are loads and loads of ways to improve the performance of ASP.NET
>sites, but ViewState is IMO opinion fairly far down the list.
>>...
>By all means be aware that it's always a "good thing" to minimise the
>amount
>of traffic between server and client and back again, so set
>EnableViewState="false" for all those controls which don't need it - but
>it's really not necessary to devote any more time to it than that...


>
>
While I agree with you, I am working with the wizard control and
viewstate gets out of hand really quick :)


Hmm - it shouldn't if you're careful... You really only need to enable
ViewState on the controls within the individual panels...

That said, I really don't like the Wizard control / <asp:MultiViewcontrol
for just this reason...

It also makes client-side validation almost impossible because only the
controls in the current panel are actually streamed down to the client...

I really wish Microsoft had come up with something along the lines of the
old IE:WebControls for this in ASP.NET 2...I realise that they were for IE
only but, in an enclosed corporate intranet where all client machines are
running IE, the IE:WebControls were truly superb...

Monday, March 26, 2012

Server side viewstate

In looking for a way to trim down viewstate, I came across the
following articles to store viewstate in session:
http://aspalliance.com/72
http://msdn.microsoft.com/library/d...
rst.asp
It appears as if the first link is actually better as it allows for a
"history" of viewstates to be availabale.
Anyone have experience using either one of these methods?
Thanks."emde" <emdeusenet@.yahoo.com> wrote in message
news:1161638474.044477.141050@.b28g2000cwb.googlegroups.com...

> In looking for a way to trim down viewstate, I came across the
> following articles to store viewstate in session:
> http://aspalliance.com/72
> http://msdn.microsoft.com/library/d...r />
tPrst.asp
>
> It appears as if the first link is actually better as it allows for a
> "history" of viewstates to be availabale.
> Anyone have experience using either one of these methods?
ViewState, as with hundreds of other features of ASP.NET, is extremely
useful when it's extremely useful.
But let's not get too carried away here - ViewState *does* add a bit of
overhead to every page which uses it, but unless the page is huge with loads
and loads of WebControls and HTMLControls, it's probably not going to make
that much of a difference to most users. It's just text after all. The page
may take a second or so longer to load, but that's about it...
If the page is huge with loads and loads of WebControls and HTMLControls,
then it's been badly designed in the first place, so ViewState really is the
least of your worries...:-)
There are loads and loads of ways to improve the performance of ASP.NET
sites, but ViewState is IMO opinion fairly far down the list.
By all means be aware that it's always a "good thing" to minimise the amount
of traffic between server and client and back again, so set
EnableViewState="false" for all those controls which don't need it - but
it's really not necessary to devote any more time to it than that...
Mark Rae wrote:

> There are loads and loads of ways to improve the performance of ASP.NET
> sites, but ViewState is IMO opinion fairly far down the list.
>...
> By all means be aware that it's always a "good thing" to minimise the amou
nt
> of traffic between server and client and back again, so set
> EnableViewState="false" for all those controls which don't need it - but
> it's really not necessary to devote any more time to it than that...
While I agree with you, I am working with the wizard control and
viewstate gets out of hand really quick :)
"emde" <emdeusenet@.yahoo.com> wrote in message
news:1161639998.986367.317610@.e3g2000cwe.googlegroups.com...

> Mark Rae wrote:
>
>
> While I agree with you, I am working with the wizard control and
> viewstate gets out of hand really quick :)
Hmm - it shouldn't if you're careful... You really only need to enable
ViewState on the controls within the individual panels...
That said, I really don't like the Wizard control / <asp:MultiView> control
for just this reason...
It also makes client-side validation almost impossible because only the
controls in the current panel are actually streamed down to the client...
I really wish Microsoft had come up with something along the lines of the
old IE:WebControls for this in ASP.NET 2...I realise that they were for IE
only but, in an enclosed corporate intranet where all client machines are
running IE, the IE:WebControls were truly superb...

Tuesday, March 13, 2012

Server.MapPath - Embarrasingly simple question

Hello All

I am trying to learn C# after having always worked with VB and I have come across a really stupid problem.

In VB.Net I know the code would be:

blah=Server.MapPath("files\" & Session("myFolder"))

in c# I have written it as

blah= Server.MapPath("files\" + Session["myFolder"])

but I get blue sqiggles under the "myFolder". what am I doing wrong?

Please Help!

Bex

The code has to be as

blah=Server.MapPath(@."files\" + Session["myFolder"].ToString());

Session variable has to be converted to string.

@. symbol used to handle string without escape sequence