Thursday, March 22, 2012
HTML Contents in GridView Rows Will Not Display as HTML?
I am trying to read a directory listing into a string[] and then use
that data, along with some other data, to create HTML for display in a
gridview row. A sample item in the string[] might look like this...
<div style='vertical-align:middle;'><img src='image.jpb'><a
href='somefile.zip'>somefile.zip</a></div>
I then bind the array to a gridview to show on the form.
This always worked great with a datagrid in VS2003. Now, however, the
gridview handles the HTML differently: if reformats it? What I mean is,
the HTML displays as literal text...the gridview rows really show the
HTML tags (<div>, etc...). When inspecting the page with the browser's
View | Source, I can see that the page has all of the <div> as < div
>. Why is this happening, and how do I fix it? It would be great if
asp.net would not change my code!
HTML Contents in GridView Rows Will Not Display as HTML?
I am trying to read a directory listing into a string[] and then use
that data, along with some other data, to create HTML for display in a
gridview row. A sample item in the string[] might look like this...
<div style='vertical-align:middle;'><img src='image.jpb'><a
href='somefile.zip'>somefile.zip</a></div
I then bind the array to a gridview to show on the form.
This always worked great with a datagrid in VS2003. Now, however, the
gridview handles the HTML differently: if reformats it? What I mean is,
the HTML displays as literal text...the gridview rows really show the
HTML tags (<div>, etc...). When inspecting the page with the browser's
View | Source, I can see that the page has all of the <div> as < div
>. Why is this happening, and how do I fix it? It would be great if
asp.net would not change my code!
Wednesday, March 21, 2012
HTML 101 Position image relative to GridView row
things a hundred times before but I sure can't seem to get it right this tim
e.
I have a GridView with a column of text boxes. If I want to position an
image over the GridView just below, for instance, the textbox in row 4 of th
e
GridView. I don't care that it covers the other textboxes. I am
successfully obtaining the textbox and the image objects in client-side
javascript using document.getElementById().
I can position the image just fine. I just can't seem to get the position
of the chosen textbox relative to the screen or client area of the browser.
textBox.offsetTop = 2 // this seems to be the position relative to the cell
in the table of the rendered GridView
textBox.clientTop = 2 // this seems to be the position relative to the cell
in the table of the rendered GridView
textBox.style.pixelTop = 0
textBox.style.top = // empty
Dale Preston
MCAD C#
MCSE, MCDBAI clicked "post" too quickly. I wish there was a Review button to see your
post before finally submitting it.
Anyway, what my original post left out is what it is I am looking for:
Can anyone help me with how to get the location of an item in a GridView
row, in my case the textbox, in relation to either the document or in
relation to the client area of the browser so that I can position my image i
n
relation to that textbox?
Thanks,
Dale
--
Dale Preston
MCAD C#
MCSE, MCDBA
"Dale" wrote:
> This seems like it should be simple and I am pretty sure I've done similar
> things a hundred times before but I sure can't seem to get it right this t
ime.
> I have a GridView with a column of text boxes. If I want to position an
> image over the GridView just below, for instance, the textbox in row 4 of
the
> GridView. I don't care that it covers the other textboxes. I am
> successfully obtaining the textbox and the image objects in client-side
> javascript using document.getElementById().
> I can position the image just fine. I just can't seem to get the position
> of the chosen textbox relative to the screen or client area of the browser
.
> textBox.offsetTop = 2 // this seems to be the position relative to the cel
l
> in the table of the rendered GridView
> textBox.clientTop = 2 // this seems to be the position relative to the cel
l
> in the table of the rendered GridView
> textBox.style.pixelTop = 0
> textBox.style.top = // empty
>
> --
> Dale Preston
> MCAD C#
> MCSE, MCDBA
I solved my own problem. The solution is to add a POSITION style value of
"relative" to the textbox. Then offsetTop and offsetLeft provide real value
s
relative to the client area.
Dale Preston
MCAD C#
MCSE, MCDBA
"Dale" wrote:
> This seems like it should be simple and I am pretty sure I've done similar
> things a hundred times before but I sure can't seem to get it right this t
ime.
> I have a GridView with a column of text boxes. If I want to position an
> image over the GridView just below, for instance, the textbox in row 4 of
the
> GridView. I don't care that it covers the other textboxes. I am
> successfully obtaining the textbox and the image objects in client-side
> javascript using document.getElementById().
> I can position the image just fine. I just can't seem to get the position
> of the chosen textbox relative to the screen or client area of the browser
.
> textBox.offsetTop = 2 // this seems to be the position relative to the cel
l
> in the table of the rendered GridView
> textBox.clientTop = 2 // this seems to be the position relative to the cel
l
> in the table of the rendered GridView
> textBox.style.pixelTop = 0
> textBox.style.top = // empty
>
> --
> Dale Preston
> MCAD C#
> MCSE, MCDBA
HTML 101 Position image relative to GridView row
things a hundred times before but I sure can't seem to get it right this time.
I have a GridView with a column of text boxes. If I want to position an
image over the GridView just below, for instance, the textbox in row 4 of the
GridView. I don't care that it covers the other textboxes. I am
successfully obtaining the textbox and the image objects in client-side
javascript using document.getElementById().
I can position the image just fine. I just can't seem to get the position
of the chosen textbox relative to the screen or client area of the browser.
textBox.offsetTop = 2 // this seems to be the position relative to the cell
in the table of the rendered GridView
textBox.clientTop = 2 // this seems to be the position relative to the cell
in the table of the rendered GridView
textBox.style.pixelTop = 0
textBox.style.top = // empty
--
Dale Preston
MCAD C#
MCSE, MCDBAI clicked "post" too quickly. I wish there was a Review button to see your
post before finally submitting it.
Anyway, what my original post left out is what it is I am looking for:
Can anyone help me with how to get the location of an item in a GridView
row, in my case the textbox, in relation to either the document or in
relation to the client area of the browser so that I can position my image in
relation to that textbox?
Thanks,
Dale
--
Dale Preston
MCAD C#
MCSE, MCDBA
"Dale" wrote:
Quote:
Originally Posted by
This seems like it should be simple and I am pretty sure I've done similar
things a hundred times before but I sure can't seem to get it right this time.
>
I have a GridView with a column of text boxes. If I want to position an
image over the GridView just below, for instance, the textbox in row 4 of the
GridView. I don't care that it covers the other textboxes. I am
successfully obtaining the textbox and the image objects in client-side
javascript using document.getElementById().
>
I can position the image just fine. I just can't seem to get the position
of the chosen textbox relative to the screen or client area of the browser.
>
textBox.offsetTop = 2 // this seems to be the position relative to the cell
in the table of the rendered GridView
>
textBox.clientTop = 2 // this seems to be the position relative to the cell
in the table of the rendered GridView
>
textBox.style.pixelTop = 0
>
textBox.style.top = // empty
>
>
--
Dale Preston
MCAD C#
MCSE, MCDBA
I solved my own problem. The solution is to add a POSITION style value of
"relative" to the textbox. Then offsetTop and offsetLeft provide real values
relative to the client area.
--
Dale Preston
MCAD C#
MCSE, MCDBA
"Dale" wrote:
Quote:
Originally Posted by
This seems like it should be simple and I am pretty sure I've done similar
things a hundred times before but I sure can't seem to get it right this time.
>
I have a GridView with a column of text boxes. If I want to position an
image over the GridView just below, for instance, the textbox in row 4 of the
GridView. I don't care that it covers the other textboxes. I am
successfully obtaining the textbox and the image objects in client-side
javascript using document.getElementById().
>
I can position the image just fine. I just can't seem to get the position
of the chosen textbox relative to the screen or client area of the browser.
>
textBox.offsetTop = 2 // this seems to be the position relative to the cell
in the table of the rendered GridView
>
textBox.clientTop = 2 // this seems to be the position relative to the cell
in the table of the rendered GridView
>
textBox.style.pixelTop = 0
>
textBox.style.top = // empty
>
>
--
Dale Preston
MCAD C#
MCSE, MCDBA