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

Wednesday, March 28, 2012

substitute for <span>

asp.net 1.1

for my .aspx web-form , if i set Target Schema = Internet Explorer 5.0 ,
then this line

<span id="NameFirst" name="NameFirst" runat=server></span
causes the error

"the active schema does not support the element 'span'."

what should i use as a substitute for <span> ?That's weird -- span sure is supported by IE5. I can repro your problem only if I switch the schema to IE 3.2/Netscape 3.02 -- in other words, using a schema for a browser before IE4.

For what it's worth, the schema is used for validation in HTML view, but it does not prevent the page from compiling and rendering to the browser. At least, that's my experience while testing this.
Unless you have a good reason for specifying the Target Schema, it would bemuch easier to simply remove that specification. The <span> tag is a very fundamental part of both HTML and ASP.NET, so trying to remove every instance of it would bevery problematic.

However, to answer your question ... you could use a <div> instead.

A <div> is called a "block" element in that each <div> tends to appear "under" the last <div>. (HTML tables are block elements too, as they each generally appear below one another.)

A <span>, on the other hand, is called an "inline" element as each <span> appears "next" to the last <span>. (HTML hyperlinks <a href="http://links.10026.com/?link=..."> are inline elements, as they appear next to the words preceding the hyperlink.)

So, to use a <div> instead of a <span>, you'd need to change it from a "block" element to an "inline" element:

<div id="one" style="display:inline;">...</div>
is pretty much the same as
<span id="two">...</span>

Still, I'd caution again that it would be much easier to remove the Target Schema specification than to try to remove all instances of <span> tags.

Substring

In an aspx (asp2.0) page in C# I have a string array. The array contains
letters separated into two groups by a dash (-). I want to obtain the
letters before the dash. I use the following code. Strangely, when the
array has a value of "MOD-AS" Label3 displays "3" while Label4 displays -1.
What's going on ? What is changing the value of variable mn ? Thanks,
Jim
int i = 32;
string s1;
string s2;
s1 = Ante_Arr[i];
int mn = s1.IndexOf("-");
Label3.Text = mn.ToString(); // the displayed value is 3
try
{
s2 = s1.Substring(1, mn); // throws an error: length can not be less
than zero
}
catch
{
Label4.Text = mn.ToString(); // the displayed value is -1
}Maybe it's scope?
Put the int mn = s1.IndexOf("-"); line into the try block, or take a look at
the value of mn before the s2 = s1.Substring(1, mn); line.
"Jim McGivney" <mcgiv1@.no-spam.sbcglobal.net> wrote in message
news:O7EM879dGHA.3348@.TK2MSFTNGP03.phx.gbl...
> In an aspx (asp2.0) page in C# I have a string array. The array contains
> letters separated into two groups by a dash (-). I want to obtain the
> letters before the dash. I use the following code. Strangely, when the
> array has a value of "MOD-AS" Label3 displays "3" while Label4
> displays -1.
> What's going on ? What is changing the value of variable mn ? Thanks,
> Jim
> int i = 32;
> string s1;
> string s2;
> s1 = Ante_Arr[i];
> int mn = s1.IndexOf("-");
> Label3.Text = mn.ToString(); // the displayed value is 3
> try
> {
> s2 = s1.Substring(1, mn); // throws an error: length can not be less
> than zero
> }
> catch
> {
> Label4.Text = mn.ToString(); // the displayed value is -1
> }
>

Substring

In an aspx (asp2.0) page in C# I have a string array. The array contains
letters separated into two groups by a dash (-). I want to obtain the
letters before the dash. I use the following code. Strangely, when the
array has a value of "MOD-AS" Label3 displays "3" while Label4 displays -1.
What's going on ? What is changing the value of variable mn ? Thanks,
Jim

int i = 32;
string s1;
string s2;
s1 = Ante_Arr[i];
int mn = s1.IndexOf("-");
Label3.Text = mn.ToString(); // the displayed value is 3
try
{
s2 = s1.Substring(1, mn); // throws an error: length can not be less
than zero
}
catch
{
Label4.Text = mn.ToString(); // the displayed value is -1
}Maybe it's scope?

Put the int mn = s1.IndexOf("-"); line into the try block, or take a look at
the value of mn before the s2 = s1.Substring(1, mn); line.

"Jim McGivney" <mcgiv1@.no-spam.sbcglobal.net> wrote in message
news:O7EM879dGHA.3348@.TK2MSFTNGP03.phx.gbl...
> In an aspx (asp2.0) page in C# I have a string array. The array contains
> letters separated into two groups by a dash (-). I want to obtain the
> letters before the dash. I use the following code. Strangely, when the
> array has a value of "MOD-AS" Label3 displays "3" while Label4
> displays -1.
> What's going on ? What is changing the value of variable mn ? Thanks,
> Jim
> int i = 32;
> string s1;
> string s2;
> s1 = Ante_Arr[i];
> int mn = s1.IndexOf("-");
> Label3.Text = mn.ToString(); // the displayed value is 3
> try
> {
> s2 = s1.Substring(1, mn); // throws an error: length can not be less
> than zero
> }
> catch
> {
> Label4.Text = mn.ToString(); // the displayed value is -1
> }

Sudden Cookie problem is .aspx page


Cookie problem in .aspx application.

I have a cookie problem that makes no sense. I get this error when the page
loads:

Object reference not set to an instance of an object.

I am reading the cookie into a var with standard code.

Where the problem makes no sense is that this application sits on my
network, and all
other machines load the page fine. As has the page loaded on all machines
fine since the application
has been in development. Only now, there seems to be a problem.

The other machines are running XP Pro and Windows 2000 Pro, respectfully.
The machine that throws the error is running XP.

All machines have been updated regularly.

Does any know what in the world could be happening with the XP machine for
it never loads the cookie when the page is requested? (note, no privacy
changes have been made to the browser on the XP machine and the machine is
virus free)

Any help would be greatly appreciated.

Branton EllerbeePost your code please

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
"branton ellerbee" <blrb@.sbcglobal.net> wrote in message
news:3olOb.6716$kg1.1173@.newssvr24.news.prodigy.co m...
>
> Cookie problem in .aspx application.
> I have a cookie problem that makes no sense. I get this error when the
page
> loads:
> Object reference not set to an instance of an object.
> I am reading the cookie into a var with standard code.
> Where the problem makes no sense is that this application sits on my
> network, and all
> other machines load the page fine. As has the page loaded on all machines
> fine since the application
> has been in development. Only now, there seems to be a problem.
> The other machines are running XP Pro and Windows 2000 Pro, respectfully.
> The machine that throws the error is running XP.
> All machines have been updated regularly.
> Does any know what in the world could be happening with the XP machine for
> it never loads the cookie when the page is requested? (note, no privacy
> changes have been made to the browser on the XP machine and the machine is
> virus free)
> Any help would be greatly appreciated.
> Branton Ellerbee

Tuesday, March 13, 2012

Swapping Image Url

In an aspx page I have declared an Image control:
<asp:Image id="myImage" runat="server"></asp:Image
In the code-behind I populate it's ImageURL property, like this:
myImage.ImageUrl = "some.gif";

Then, in client-side JavaScript, the user can cause the image to be
replaced, like this:
document.all("myImage").src = "other.gif";

Here's the problem: on postback, the image control's .ImageUrl property
still contains "some.gif" and not "other.gif" as I am needing.

What do I need to do to receive - during postback - the value set in the
client by the JavaScript?

Thanks!After postback, the value of ImageUrl is coming from the control's ViewState.

One solution would be to set the value of a hidden field when you set the
image's src attribute. The value of the hidden field will get posted back
correctly.

"Guadala Harry" wrote:

> In an aspx page I have declared an Image control:
> <asp:Image id="myImage" runat="server"></asp:Image>
> In the code-behind I populate it's ImageURL property, like this:
> myImage.ImageUrl = "some.gif";
> Then, in client-side JavaScript, the user can cause the image to be
> replaced, like this:
> document.all("myImage").src = "other.gif";
> Here's the problem: on postback, the image control's .ImageUrl property
> still contains "some.gif" and not "other.gif" as I am needing.
> What do I need to do to receive - during postback - the value set in the
> client by the JavaScript?
> Thanks!
>
>
Thanks - I thought about going the hidden field route - but was hoping for
some solution that wouldn't require adding another field or control that
needs synchronizing with the original Image control.

Any other ideas?

Thanks again...

-G

"Brad Quinn" <BradQuinn@.discussions.microsoft.com> wrote in message
news:E07F8EE9-B35D-488C-A2A9-CB60DCA6AACD@.microsoft.com...
> After postback, the value of ImageUrl is coming from the control's
ViewState.
> One solution would be to set the value of a hidden field when you set the
> image's src attribute. The value of the hidden field will get posted back
> correctly.
> "Guadala Harry" wrote:
> > In an aspx page I have declared an Image control:
> > <asp:Image id="myImage" runat="server"></asp:Image>
> > In the code-behind I populate it's ImageURL property, like this:
> > myImage.ImageUrl = "some.gif";
> > Then, in client-side JavaScript, the user can cause the image to be
> > replaced, like this:
> > document.all("myImage").src = "other.gif";
> > Here's the problem: on postback, the image control's .ImageUrl property
> > still contains "some.gif" and not "other.gif" as I am needing.
> > What do I need to do to receive - during postback - the value set in the
> > client by the JavaScript?
> > Thanks!
Can you make the code in your codebehind only execute the first time it
executes? i.e.

if (!Page.IsPostback)
myImage.ImageUrl = "some.gif";

Toby Mathews

"Guadala Harry" <GMan@.NoSpam.com> wrote in message
news:%23wqVQXQgEHA.2908@.TK2MSFTNGP10.phx.gbl...
> Thanks - I thought about going the hidden field route - but was hoping for
> some solution that wouldn't require adding another field or control that
> needs synchronizing with the original Image control.
> Any other ideas?
> Thanks again...
> -G
>
> "Brad Quinn" <BradQuinn@.discussions.microsoft.com> wrote in message
> news:E07F8EE9-B35D-488C-A2A9-CB60DCA6AACD@.microsoft.com...
> > After postback, the value of ImageUrl is coming from the control's
> ViewState.
> > One solution would be to set the value of a hidden field when you set
the
> > image's src attribute. The value of the hidden field will get posted
back
> > correctly.
> > "Guadala Harry" wrote:
> > > In an aspx page I have declared an Image control:
> > > <asp:Image id="myImage" runat="server"></asp:Image>
> > > > In the code-behind I populate it's ImageURL property, like this:
> > > myImage.ImageUrl = "some.gif";
> > > > Then, in client-side JavaScript, the user can cause the image to be
> > > replaced, like this:
> > > document.all("myImage").src = "other.gif";
> > > > Here's the problem: on postback, the image control's .ImageUrl
property
> > > still contains "some.gif" and not "other.gif" as I am needing.
> > > > What do I need to do to receive - during postback - the value set in
the
> > > client by the JavaScript?
> > > > Thanks!
> > > >
That's not really relevant to the problem - it would be IF there was an
issue with postback processing walking on the value set in the client - but
issue is that the value set in the client code is never making it to the
server (unless I explicitly stuff the value into a hidden field - which I
don't want to do unless I really must).

Thanks anyway.

"Toby Mathews" <tobymathewsNOSPAM@.yahoo.spamfree.co.uk> wrote in message
news:cfhs1q$87n$1@.thorium.cix.co.uk...
> Can you make the code in your codebehind only execute the first time it
> executes? i.e.
> if (!Page.IsPostback)
> myImage.ImageUrl = "some.gif";
> Toby Mathews
> "Guadala Harry" <GMan@.NoSpam.com> wrote in message
> news:%23wqVQXQgEHA.2908@.TK2MSFTNGP10.phx.gbl...
> > Thanks - I thought about going the hidden field route - but was hoping
for
> > some solution that wouldn't require adding another field or control that
> > needs synchronizing with the original Image control.
> > Any other ideas?
> > Thanks again...
> > -G
> > "Brad Quinn" <BradQuinn@.discussions.microsoft.com> wrote in message
> > news:E07F8EE9-B35D-488C-A2A9-CB60DCA6AACD@.microsoft.com...
> > > After postback, the value of ImageUrl is coming from the control's
> > ViewState.
> > > > One solution would be to set the value of a hidden field when you set
> the
> > > image's src attribute. The value of the hidden field will get posted
> back
> > > correctly.
> > > > "Guadala Harry" wrote:
> > > > > In an aspx page I have declared an Image control:
> > > > <asp:Image id="myImage" runat="server"></asp:Image>
> > > > > > In the code-behind I populate it's ImageURL property, like this:
> > > > myImage.ImageUrl = "some.gif";
> > > > > > Then, in client-side JavaScript, the user can cause the image to be
> > > > replaced, like this:
> > > > document.all("myImage").src = "other.gif";
> > > > > > Here's the problem: on postback, the image control's .ImageUrl
> property
> > > > still contains "some.gif" and not "other.gif" as I am needing.
> > > > > > What do I need to do to receive - during postback - the value set in
> the
> > > > client by the JavaScript?
> > > > > > Thanks!
> > > > > > > >
Harry,

Sorry, I didn't read your message properly first time round. I'm not sure
how else you could achieve what you want to do other than how you decribe.
Good luck,

Toby

"Guadala Harry" <GMan@.NoSpam.com> wrote in message
news:%23Tkt9DRgEHA.1048@.tk2msftngp13.phx.gbl...
> That's not really relevant to the problem - it would be IF there was an
> issue with postback processing walking on the value set in the client -
but
> issue is that the value set in the client code is never making it to the
> server (unless I explicitly stuff the value into a hidden field - which I
> don't want to do unless I really must).
> Thanks anyway.
>
> "Toby Mathews" <tobymathewsNOSPAM@.yahoo.spamfree.co.uk> wrote in message
> news:cfhs1q$87n$1@.thorium.cix.co.uk...
> > Can you make the code in your codebehind only execute the first time it
> > executes? i.e.
> > if (!Page.IsPostback)
> > myImage.ImageUrl = "some.gif";
> > Toby Mathews
> > "Guadala Harry" <GMan@.NoSpam.com> wrote in message
> > news:%23wqVQXQgEHA.2908@.TK2MSFTNGP10.phx.gbl...
> > > Thanks - I thought about going the hidden field route - but was hoping
> for
> > > some solution that wouldn't require adding another field or control
that
> > > needs synchronizing with the original Image control.
> > > > Any other ideas?
> > > > Thanks again...
> > > > -G
> > > > > > "Brad Quinn" <BradQuinn@.discussions.microsoft.com> wrote in message
> > > news:E07F8EE9-B35D-488C-A2A9-CB60DCA6AACD@.microsoft.com...
> > > > After postback, the value of ImageUrl is coming from the control's
> > > ViewState.
> > > > > > One solution would be to set the value of a hidden field when you
set
> > the
> > > > image's src attribute. The value of the hidden field will get
posted
> > back
> > > > correctly.
> > > > > > "Guadala Harry" wrote:
> > > > > > > In an aspx page I have declared an Image control:
> > > > > <asp:Image id="myImage" runat="server"></asp:Image>
> > > > > > > > In the code-behind I populate it's ImageURL property, like this:
> > > > > myImage.ImageUrl = "some.gif";
> > > > > > > > Then, in client-side JavaScript, the user can cause the image to
be
> > > > > replaced, like this:
> > > > > document.all("myImage").src = "other.gif";
> > > > > > > > Here's the problem: on postback, the image control's .ImageUrl
> > property
> > > > > still contains "some.gif" and not "other.gif" as I am needing.
> > > > > > > > What do I need to do to receive - during postback - the value set
in
> > the
> > > > > client by the JavaScript?
> > > > > > > > Thanks!
> > > > > > > > > > > > > >

Swapping Image Url

In an aspx page I have declared an Image control:
<asp:Image id="myImage" runat="server"></asp:Image>
In the code-behind I populate it's ImageURL property, like this:
myImage.ImageUrl = "some.gif";
Then, in client-side JavaScript, the user can cause the image to be
replaced, like this:
document.all("myImage").src = "other.gif";
Here's the problem: on postback, the image control's .ImageUrl property
still contains "some.gif" and not "other.gif" as I am needing.
What do I need to do to receive - during postback - the value set in the
client by the JavaScript?
Thanks!After postback, the value of ImageUrl is coming from the control's ViewState
.
One solution would be to set the value of a hidden field when you set the
image's src attribute. The value of the hidden field will get posted back
correctly.
"Guadala Harry" wrote:

> In an aspx page I have declared an Image control:
> <asp:Image id="myImage" runat="server"></asp:Image>
> In the code-behind I populate it's ImageURL property, like this:
> myImage.ImageUrl = "some.gif";
> Then, in client-side JavaScript, the user can cause the image to be
> replaced, like this:
> document.all("myImage").src = "other.gif";
> Here's the problem: on postback, the image control's .ImageUrl property
> still contains "some.gif" and not "other.gif" as I am needing.
> What do I need to do to receive - during postback - the value set in the
> client by the JavaScript?
> Thanks!
>
>
Thanks - I thought about going the hidden field route - but was hoping for
some solution that wouldn't require adding another field or control that
needs synchronizing with the original Image control.
Any other ideas?
Thanks again...
-G
"Brad Quinn" <BradQuinn@.discussions.microsoft.com> wrote in message
news:E07F8EE9-B35D-488C-A2A9-CB60DCA6AACD@.microsoft.com...
> After postback, the value of ImageUrl is coming from the control's
ViewState.
> One solution would be to set the value of a hidden field when you set the
> image's src attribute. The value of the hidden field will get posted back
> correctly.
> "Guadala Harry" wrote:
>
Can you make the code in your codebehind only execute the first time it
executes? i.e.
if (!Page.IsPostback)
myImage.ImageUrl = "some.gif";
Toby Mathews
"Guadala Harry" <GMan@.NoSpam.com> wrote in message
news:%23wqVQXQgEHA.2908@.TK2MSFTNGP10.phx.gbl...
> Thanks - I thought about going the hidden field route - but was hoping for
> some solution that wouldn't require adding another field or control that
> needs synchronizing with the original Image control.
> Any other ideas?
> Thanks again...
> -G
>
> "Brad Quinn" <BradQuinn@.discussions.microsoft.com> wrote in message
> news:E07F8EE9-B35D-488C-A2A9-CB60DCA6AACD@.microsoft.com...
> ViewState.
the
back
property
the
>
That's not really relevant to the problem - it would be IF there was an
issue with postback processing walking on the value set in the client - but
issue is that the value set in the client code is never making it to the
server (unless I explicitly stuff the value into a hidden field - which I
don't want to do unless I really must).
Thanks anyway.
"Toby Mathews" <tobymathewsNOSPAM@.yahoo.spamfree.co.uk> wrote in message
news:cfhs1q$87n$1@.thorium.cix.co.uk...
> Can you make the code in your codebehind only execute the first time it
> executes? i.e.
> if (!Page.IsPostback)
> myImage.ImageUrl = "some.gif";
> Toby Mathews
> "Guadala Harry" <GMan@.NoSpam.com> wrote in message
> news:%23wqVQXQgEHA.2908@.TK2MSFTNGP10.phx.gbl...
for
> the
> back
> property
> the
>
Harry,
Sorry, I didn't read your message properly first time round. I'm not sure
how else you could achieve what you want to do other than how you decribe.
Good luck,
Toby
"Guadala Harry" <GMan@.NoSpam.com> wrote in message
news:%23Tkt9DRgEHA.1048@.tk2msftngp13.phx.gbl...
> That's not really relevant to the problem - it would be IF there was an
> issue with postback processing walking on the value set in the client -
but
> issue is that the value set in the client code is never making it to the
> server (unless I explicitly stuff the value into a hidden field - which I
> don't want to do unless I really must).
> Thanks anyway.
>
> "Toby Mathews" <tobymathewsNOSPAM@.yahoo.spamfree.co.uk> wrote in message
> news:cfhs1q$87n$1@.thorium.cix.co.uk...
> for
that
set
posted
be
in
>

swf files?

How do I add swf files to my aspx page? A master page to be more precise.

There's no reason why you shouldn't just use the <object> and <embed> html syntax like you would in any other html-emitting language...

there's also controls like this (http://www.codeproject.com/aspnet/AspNetFlashMovieControl.asp) that may or not make it easier to do so


You do it the same way you would do it with a standard HTML file.

Switch two gridViews, but put in the same place, how to do it ?

if click_button1, then gridView1.visible=true

if click_button2, then show gridView2.visible=true

but, How to layout them in myFile.aspx ? I want to show them in the same place, switch from one to another ?

Just place them one after the other

<asp:GridViewID="GridView1"runat="server"> ...</asp:GridView><asp:GridViewID="GridView2"runat="server"> ... </asp:GridView>

Then in the button 1 event handler you have:

GridView1.Visible = true;
GridView2.Visible = false;


Mark as ANSWER. Thanks.