|
norm,
On question 1, you need to invoke a helper function in the code behind. You will have to set Autogenerate columns to false to customize the datagrid. Something similar to the following:
--.aspx page in the item template tag
<code><%# functionname(databinder.eval(container.dataitem("columnname")) %></code>
--code behind (sorry, but I am most familiar with VB)
<code>Function functionname(variable as string) as string
If variable = 1 then
return html code to generate the delete link
else
return "nbsp"
End IF
End Function</code>
On questions 2, you would need to add a reference the code behid file to the html table and add attributes to that table.
<code>
Dim td1 as HTML.Column(????)
td1.Attributes.Add(onmouseover, "javacode")
</code>
I am not 100% sure on the syntax of this one, since I am trying to write this from memeory and I haven't done a lot of java coding yet in my applications, but take a look at the attributes add portion and it should point you in the right direction.
Hope this helps.
Jeremy Oldham
P.S. Did you ever get the problem with the cursor fixed?
|
|
|
|
|
Thanks. Sorry that it took so long to reply, I had to reinstall my machine last nite. I think most work should be done in onpage_load. Anyway, here's the feedback:
Question 1: Pseudo code only. I'm starting out on C# and VB.NET too.
'Note: I think the logic should best be implemented on Page_load dont you think?
Sub Page_load(variable as string) as string
Rows = Me.dgGrid.Rows
For Each row in Rows
If row("column1")='James' Then 'Do you think this is the way to go?
row("column2").visible = true 'Is this the right property to use? If not, which?
else
row("column2").visible = false
Next
End Sub
Question 2:
Dim td1 as HTML.Column(????) 'Column?? U mean 'Rows' do you? How exactly will you code this?
td1.Attributes.Add(onmouseover, "javacode") 'How can you pass parameter to event handler?
... let's see, do u think this will work?
Page_Load(..)
...
Rows = Me.dgGrid.Rows
For Each row in Rows
row.Attributes.Add(OnMouseOver, "SetHighlite") 'Referencing client side script? Any problem?
Next
...
End Sub
Can you give a small functional code snippet on eventhandler SetHighlite? I'm not familiar with clientside scripting "object" model... I think for highlite:
bgColor='Blue';
but not good at Javascripts.
QUESTION 3:
The cursor problem? Yes, it's solved. You want to know how?
|
|
|
|
|
norm,
Instead of the Page_onload portion, you should use the datagrid's OnItemDatabound method. Then you would use somthing like:
If e.Item.ItemType = E.Item.ItemType.Item or e.Item.ItemType = e.Item.ItemType.AlternatingItem then
If e.Item("Column1") = "James" then
e.Item("Column2") = " "
End If
End If
You cannot his the column, bcause it will hide all rows in the column and not just the single cell.
As far as the javascript code, I cannot help you alot because again I do not know much java. Basically though you are adding either the javascript code or the javascript function name and parameters in place of the SetHighlite part below.
row.Attributes.Add(onmouseover, "SetHighlite")
If you need to pass parameter or variables the concatenate them.
row.Attributes.Add(onmouseover, "SetHighlite(" & variable1 & ")")
Hopefully someone here can help you with the javascript.
As far as the cursor problem, I still think that whatever you are doing with a cursor in SQL could be solved with a properly written SQL statement and that it would probably be more sufficient. If you want me to take a look at it, I would be more than willing to help out.
Jeremy
Jeremy Oldham
|
|
|
|
|
norm,
I looked at your first post again this morning and tested a few things on my server. I have also attached a good link to help with some of the javascript I used in the code below. Hope this helps. I used a datagrid with AutogenerateColumns set to True.
<br />
Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemDataBound<br />
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then<br />
e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='Silver'")<br />
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='White'")<br />
If e.Item.DataItem("ShowMobile") Then<br />
e.Item.Cells(6).Text = "Yes"<br />
Else<br />
e.Item.Cells(6).Text = " "<br />
End If<br />
End If<br />
End Sub<br />
In this sample I do two things. 1) If it is a Item or alternating Item, then I add the javascript to highlight the row onMouseOver and unhighlight onMouseOut. e.Item refers to the current row of the datagrid. 2) I check the "ShowMobile" column of the current row and if it is true as returned from the database, then I change the text of a cell to Yes, if not, I blank the text out of the cell. You should be able to do something similar for your Delete button.
Be very careful about the javascript as it seems to be case sensative.
http://aspalliance.com/Colt/Articles/Article3.aspx[^]
Good Luck!
Jeremy Oldham
|
|
|
|
|
damn, just tried the code and also found a reference from: http://www.dotnetjohn.com/articles/articleid12.aspx
I set up the event handler for DataGrid's OnItemDataBound event as indicated in the tutorial. Code fragment:
e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='Silver'");
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='white'");
The browser is complaining: error: Object required: "this"
I am having the same problem with HTML table row (btw, can you access HTML table and set its width? Intellisense does not offer Width property on code behind: this.FindControl("myHtmlTab").Width not supported)!
anyway, error message is the same when I mouseover. "this" object is NOT allowed... I have no idea why... If I remove "this", the browser stop bitching, but at the same time, I dont get any mouseover effect.
Also, onmouseout='white' in the code fragment --> But my datagrid uses alternating color for alternating rows... any suggestion?
The center of the problem has always been "this" object!?!
norm
|
|
|
|
|
Norm,
Is there a test page I could look at? I would like to see the html code that is being built by the .aspx page. When you tried the demo on the link I gave you earlier, did you get the same error message? If so, then you probably haven't enable the Java Virtual Machine on the web browser.
A table row will not have a width property. You can set the width by either setting it for the table or for the columns (td element) in the table, but not the row (tr element).
To get the actual color of the item or alternating items background, the following should work:
<br />
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then<br />
If e.Item.ItemType = ListItemType.Item Then<br />
'Set Background for List Item<br />
e.Item.BackColor = System.Drawing.Color.Blue<br />
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='Blue'")<br />
Else<br />
'Set Background for Alternating List Item<br />
e.Item.BackColor = System.Drawing.Color.LightBlue<br />
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='LightBlue'")<br />
End If<br />
e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='Silver'")<br />
If e.Item.DataItem("ShowMobile") Then<br />
e.Item.Cells(6).Text = "Yes"<br />
Else<br />
e.Item.Cells(6).Text = " "<br />
End If<br />
End If<br />
I have tried to access the color properties listed in the datagrid's html coding, but have been unsucessful.
Jeremy Oldham
|
|
|
|
|
Thanks alot Jeremy. I just got home after a long day. Just got your message... let me work on it a little and I will let you know what's going on.
norm
|
|
|
|
|
1. Your code snippet on mouseover is very helpful. I will try it now.
2. Just check my browser setting. I use Internet Explorer 6.0 and under:
Options
>Security
>Security Setting
>Microsoft VM
>Java Permissions
>Low Safety
So, I doubt that the problem is with my browser setting.
My aspx code (Ask me for a complete file if you wish I can send it to you):
<table id="tblNavMenu" width="220" align="left" runat="server">
<tr onmousedown="Login()" id="rwLogin" onmouseover="document.getElementByID(rwLogin).bgColor='LightSteelBlue'" style="CURSOR: hand" onmouseout="document.getElementByID(rwLogin).bgColor='Ivory'">
<td align="middle"><font face="Verdana" color="darkslategray" size="2"><b>Login</b></font>
</td>
</tr>
<tr onmousedown="Logout()" id="rwLogout" onmouseover="this.bgColor='LightSteelBlue'" style="CURSOR: hand" onmouseout="this.bgColor='Ivory'">
<td align="middle"><font face="Verdana" color="darkslategray" size="2"><b>Logout</b></font>
</td>
</tr>
<tr onmousedown="NewReg()" id="rwRegister" onmouseover="this.bgColor='LightSteelBlue'" style="CURSOR: hand" onmouseout="this.bgColor='Ivory'">
<td align="middle"><font face="Verdana" color="darkslategray" size="2"><b>Register</b></font>
</td>
</tr>
<tr onmousedown="UnReg()" id="rwUnReg" onmouseover="this.bgColor='LightSteelBlue'" style="CURSOR: hand" onmouseout="this.bgColor='Ivory'">
<td align="middle"><font face="Verdana" color="darkslategray" size="2"><b>UnRegister User
Account</b></font>
</td>
</tr>
<tr onmousedown="ChangeProfile()" id="rwChangeProfile" onmouseover="this.bgColor='LightSteelBlue'" style="CURSOR: hand" onmouseout="this.bgColor='Ivory'">
<td align="middle"><font face="Verdana" color="darkslategray" size="2"><b>Change Personal
Profile</b></font>
</td>
</tr>
<tr onmousedown="TransferMasterForum()" id="rwForum" onmouseover="this.bgColor='LightSteelBlue'" style="CURSOR: hand" onmouseout="this.bgColor='Ivory'">
<td align="middle"><font face="Verdana" color="darkslategray" size="2"><b>Forums</b></font>
</td>
</tr>
<tr onmousedown="GoHome()" id="rwHome" onmouseover="this.bgColor='LightSteelBlue'" style="CURSOR: hand" onmouseout="this.bgColor='Ivory'">
<td align="middle"><font face="Verdana" color="darkslategray" size="2"><b>Home</b></font>
</td>
</tr>
</table>
That's it. Note that I did things differently in row 1 (in comparison with the rest of the grid. I use the "document" object - but none worked anyway.)
Thanks.
norm
|
|
|
|
|
Help! error: Object required "this".
I just did testing on your code in regards to onmouseover. I sufferred from the same problem working with DataGrid's "item" as data row <tr> on my HTML table.
Following is a few things I tried, I keep getting:
error: Object required: 'this'
I have tried many things and I really cant solve this. Help!
CASE 1: HTML table row
<tr onmousedown="Login()" id="rwLogin" onmouseover="document.getElementByID(rwLogin).style.backgroundColor='LightSteelBlue'" style="CURSOR: hand" onmouseout="document.getElementByID(rwLogin).style.backgroundColor='Ivory'">
<td align="middle"><font face="Verdana" color="darkslategray" size="2"><b>Login</b></font>
</td>
</tr>
CASE 2: HTML table row
<tr onmousedown="Logout()" id="rwLogout" onmouseover="this.style.backgroundColor='LightSteelBlue'" style="CURSOR: hand" onmouseout="this.style.backgroundColor='Ivory'">
<td align="middle"><font face="Verdana" color="darkslategray" size="2"><b>Logout</b></font>
</td>
</tr>
CASE 3: HTML table row
<tr onmousedown="NewReg()" id="rwRegister" onmouseover="this.bgColor='LightSteelBlue'" style="CURSOR: hand" onmouseout="this.bgColor='Ivory'">
<td align="middle"><font face="Verdana" color="darkslategray" size="2"><b>Register</b></font>
</td>
</tr>
CASE 4: DataGrid Item
//Set mouseover and mouseout attributes:
foreach( DataGridItem item in this.dgForum.Items)
{
//Mouseout:
if (item.ItemType==ListItemType.Item)
{
item.Attributes.Add("OnMouseOut", "this.style.backgroundColor='Snow'");
}
else
{
item.Attributes.Add("OnMouseOut", "this.style.backgroundColor='GhostWhite'");
}
//Mouseover:
item.Attributes.Add("OnMouseOver", "this.style.backgroundColor='Red'");
}
norm
|
|
|
|
|
norm,
If you don't mind, email me your .aspx page and I will take a look. Or if this is on an external site, I can try to hit it and see if I get the same result. Were you able to properly see the code in the Article link Demo I posted earlier? Also, send me the table structure and two or three lines of data so that I can test it in my test database.
Jeremy Oldham
|
|
|
|
|
thankyou so much. I will send it to you in three hours or so!
norm
|
|
|
|
|
Jeremy, what's your email?
norm
|
|
|
|
|
Thanks for the feedback, i got some many junk mail from spammers aronud the world that i missed your reply.
I've got QUESTION 1 and QUESTION 3. The remaining problem is QUESTION 2.
//Event handler for DataGrid's OnItemDataBound: When user mouseover/mouseout a row.
protected void ItemDataBound(Object sender, DataGridItemEventArgs e)
{
if (e.Item.ItemType==ListItemType.Item || e.Item.ItemType==ListItemType.AlternatingItem)
{
//BUG
//e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='LightSteelBlue'");
//e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='Ivory'");
}
}
But the browser keeps complaining about "this" object. Error message is:
Error: Object required: "this"
I was advised to check browser setting for Java VM - which I set to LOW - the problem persists and I doubt that Java VM setting is the problem. I have not been able to solve this problem.
norm
|
|
|
|
|
I am adding video to my personal website. All the video files are AVI files.
I am using it like this.
<embed src="ABC.AVI" height="250" width="33%" controller="true" autoplay="false" playeveryframe="false" pluginspage="oops.html" loop="false" />
1. I want to disable the right-click on the video. How to do that?
Reason : So that people won't use Full Screeen or Zoom 200%
2. How to stop the audio stream via this tag? (Embed)
I just want to give the video not audio. (mute audio)
Follow live World Cup Cricket scores here[^]
|
|
|
|
|
try this:
<embed src="http://localhost/mov_panels/AALogoAnimation.mov" width="250" height="75" type="video/quicktime" />
norm
|
|
|
|
|
If I had a suggestion for an addition to the HTML standard how would I go about proposing it?
Do I contact someone directly at the W3C?
Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
|
|
|
|
|
I think Bill Sergio tried to get the <SG> tag in, but he failed.
MyDUMeter: a .NET DUMeter clone "Thats like saying "hahahaha he doesnt know the difference between a cyberneticradioactivenuclothermolopticdimswitch and a biocontainingspherogramotron", but with words you have really never heard of."
|
|
|
|
|
Maybe they should add a <BS> tag. It might help filter out some of the BS that is on the Internet today...
Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
|
|
|
|
|
First get a job in a W3C member organization, then get assigned as a member in the W3C HTML Working Group.
|
|
|
|
|
I am getting a Server 500 error whenever I try to connect to an Access DB.
I've used the code below in an Intranet test environment and it works fine. However, when I moved this over to our external Intranet site, I get the server error. (This is the first time that I've tried to connect to a DB on this server. I can run regular ASP scripts fine). Does anyone have any clues about why this would happen? Does anything need to be set up on this server to allow it to connect to an Access DB? The web server that we are trying to get this running on is Microsoft-IIS/5.0 on Windows 2000.
Here is the code that I am using to connect:
<br />
<% @Language = VBScript %><br />
<br />
<%<br />
Dim MyConn, SQL, RS, id<br />
Set MyConn=Server.CreateObject("ADODB.Connection")<br />
MyConn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("test.mdb")<br />
SQL = "SELECT * From TEST;"<br />
Set RS = MyConn.Execute(SQL)<br />
%><br />
<br />
<html><br />
<body><br />
<table width="100%"><br />
<!-- displays news item info from database --><br />
<% <br />
While Not RS.EOF <br />
%><br />
<tr><br />
<td valign="top"><%= RS("DATA") %></td><br />
</tr><br />
<br />
<% <br />
RS.MoveNext<br />
Wend<br />
%><br />
</table><br />
<br />
<%<br />
RS.Close<br />
MyConn.Close<br />
Set RS = Nothing<br />
Set MyConn = Nothing<br />
%><br />
<br />
</body><br />
</html><br />
Chris LaQuerre
eBusiness Consultant
|
|
|
|
|
>> Does anything need to be set up on this server to allow it to connect to an Access DB?
>> "DRIVER={Microsoft Access Driver (*.mdb)};
u mean besides the driver ur telling it to use and MDAC for ADO? I don't think so.
does that help?
"No matter where you go, there your are..." - Buckaoo Banzi
-pete
|
|
|
|
|
Try going into your browser configuration and turning off the 'freindly errors' option. You should get more back than a simple '500 error' then.
Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
|
|
|
|
|
OK, here is the error that I get... Any clue what this means???
<br />
Microsoft OLE DB Provider for ODBC Drivers error '80004005' <br />
<br />
[Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key 'Temporary (volatile) Jet DSN for process 0x7d8 Thread 0x1b0 DBC 0x2e7ecc4 Jet'.
Chris LaQuerre
Internet Technologies Consultant
|
|
|
|
|
Damn, that one...
I have seen this before, and unfortunately have never been able to nail it down to exactly what causes it.
I noticed that it seemed to happen more frequently if I sent up a new copy of my database after I had edited locally.
A few things that I have done to get past it:
- Moved from a DSNless connection to using a DSN
- Moved from Access to SQL
- Stopped making additions to my database locally and sending up a new DB. I instead performed all my maintenance (record additions and deletions) via ASP pages.
Sorry I can’t help more. If you do a simple search on Google for that number you will see that there are many others out there with the same problem.
Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
|
|
|
|
|