Click here to Skip to main content
15,906,463 members
Home / Discussions / C#
   

C#

 
GeneralRe: foreach Pin
Paul Conrad27-Oct-07 11:18
professionalPaul Conrad27-Oct-07 11:18 
QuestionTo Resize Word document or Pdf file. Pin
vijaiganesh26-Oct-07 1:02
vijaiganesh26-Oct-07 1:02 
Questionswitch statement Pin
codemunkeh26-Oct-07 1:02
codemunkeh26-Oct-07 1:02 
AnswerRe: switch statement Pin
J4amieC26-Oct-07 1:05
J4amieC26-Oct-07 1:05 
GeneralRe: switch statement Pin
codemunkeh26-Oct-07 1:14
codemunkeh26-Oct-07 1:14 
GeneralRe: switch statement Pin
Urs Enzler26-Oct-07 1:24
Urs Enzler26-Oct-07 1:24 
AnswerRe: switch statement Pin
Scott Dorman26-Oct-07 3:48
professionalScott Dorman26-Oct-07 3:48 
QuestionUsing Javascript to fire an event in another class....? Pin
Dave2560026-Oct-07 0:51
Dave2560026-Oct-07 0:51 
Hi, I'm currently working on a website that has a treeview that represents folders in a virtual directory and also a datalist that allows users view files in a given folder, or text search, etc.

I am using ASP.NET and C# and hope to implement a function where if the mouse is hovering over an imagebutton in the datalist - the folder for that given file will be highlighted in the TreeView.

The TreeView and DataList are kept in diffent controls (ascx files) so I have been using EventHandlers in trying to solve my problem. Also, as far as I can tell - ASP.NET does not contain an 'onmouseover' attribute for ImageButtons so I have been using JavaScript to detect and fire the event.

The DataList is kept in its own control, which is then placed into its parent control that also holds the TreeView. There is a lot of code so I will try and submit the code that I think is relevant:

DataList Control.aspx: (javascript)

function highlightNode(event)
{
javascript:setTimeout('__doPostBack(\'<% =btnCheat.ClientID %>\',\'\')',0)
// alert(event);
}

function mouseOut(event)
{
javascript:setTimeout('__doPostBack(\'<% =btnMouseOutCheat.ClientID %>\',\'\')',0)
//alert("mouseOut")
}

This is where I believe I may be going wrong - the setTimeout means that the highlightNode function is repeatedly called with onmouseover, could someone advise on how to rewrite this diffently so that it does not repeatedly call a method?

The post backs called on each of these functions simulate the clicking of asp:buttons that will enable me to access the code-behind from the onmouseover event, here is the code-behind for the DataList control.

DataList.ascx.cs:

imgBtnFileType.Attributes["onmouseover"] = "highlightNode('" + HoverID + "')";
imgBtnFileType.Attributes["onmouseout"] = "mouseOut(event)";

These attributes are added in the ItemDataBound method for the DataList, where I add onmouseover and onmouseout to my image button. HoverID is the value I am passing to the event and is a ViewState variable that will be used to identify the Folder that I wish to highlight.

protected void btnCheat_Click(object sender, EventArgs e)
{
RaiseMouseOverEvent();
}

protected void btnMouseOutCheat_Click(object sender, EventArgs e)
{
HoverID = 0;
RaiseMouseOutEvent();
}

Above are the events called when I simulate a button click with my javascript.


public EventHandler evtMouseOver;
public EventHandler evtMouseOut;

Again, I am using EventHandlers as the TreeView is kept in a separate ascx file.

protected void RaiseMouseOutEvent()
{
if (evtMouseOut != null)
evtMouseOut(this, new EventArgs());
}

protected void RaiseMouseOverEvent()
{
if (evtMouseOver != null)
evtMouseOver(this, new EventArgs());
}

Next, here is what is going on in my other ascx file that contains both the TreeView and DataList control:

protected override void OnInit(EventArgs e)
{
base.OnInit(e);
ucDataList.evtMouseOut += new EventHandler(ucDataList_evtMouseOut);
ucDataList.evtMouseOver += new EventHandler(ucDataList_evtMouseOver);
}

The events are passed from the DataList control ^ ...

void ucDataList_evtMouseOver(object source, EventArgs e)
{
string hoverNode = ucDataList.HoverID.ToString();
tv1.FindNode(hoverNode).Select();
}

void ucDataList_evtMouseOut(object source, EventArgs e)
{
if (ucDataList.HoverID == 0)
{
if (tv1.SelectedNode != null)
tv1.SelectedNode.Selected = false;
}
}

..and the following methods ^ are called. As far as I can tell - these methods should select a given folder and unselect respectively.

Thus far, I am having the problem that I already mentioned in that the javascript is repeatedly calling the highlightNode function() when a mouseoverevent is fired and beyond that - I don't seem to be reaching the eventHandlers. I was reaching the EventHandlers at an earlier stage while debugging and not sure why I'm not anymore I don't think I've changed anything.

I hope I've been clear with my problem and would REALLY appreciate any help and advice as to finding a solution. I am new to ASP.NET, c# and javascript and apologise if I've been unclear in my explanation.

thanks,

Dave
AnswerRe: Using Javascript to fire an event in another class....? Pin
Shanmugam R26-Oct-07 1:45
Shanmugam R26-Oct-07 1:45 
GeneralRe: Using Javascript to fire an event in another class....? [modified] Pin
Dave2560026-Oct-07 2:04
Dave2560026-Oct-07 2:04 
GeneralRe: Using Javascript to fire an event in another class....? Pin
kubben26-Oct-07 3:07
kubben26-Oct-07 3:07 
GeneralRe: Using Javascript to fire an event in another class....? Pin
Dave2560026-Oct-07 3:23
Dave2560026-Oct-07 3:23 
QuestionCOM Object error Pin
DeepOceans26-Oct-07 0:50
DeepOceans26-Oct-07 0:50 
Questiondatagridview update Pin
NewToAspDotNet26-Oct-07 0:43
NewToAspDotNet26-Oct-07 0:43 
AnswerRe: datagridview update Pin
Paul Conrad27-Oct-07 12:24
professionalPaul Conrad27-Oct-07 12:24 
QuestionHow to make print job in a specific order using C# Pin
tiasoft26-Oct-07 0:26
tiasoft26-Oct-07 0:26 
AnswerRe: How to make print job in a specific order using C# Pin
Paul Conrad27-Oct-07 12:25
professionalPaul Conrad27-Oct-07 12:25 
QuestionThread & timer in Web application C# Pin
ASGuru26-Oct-07 0:18
ASGuru26-Oct-07 0:18 
AnswerRe: Thread & timer in Web application C# Pin
Christian Graus26-Oct-07 0:31
protectorChristian Graus26-Oct-07 0:31 
QuestionLoad and resize a bitmap Pin
Christian Graus26-Oct-07 0:17
protectorChristian Graus26-Oct-07 0:17 
AnswerRe: Load and resize a bitmap Pin
codemunkeh26-Oct-07 0:53
codemunkeh26-Oct-07 0:53 
GeneralRe: Load and resize a bitmap Pin
Christian Graus26-Oct-07 1:10
protectorChristian Graus26-Oct-07 1:10 
AnswerRe: Load and resize a bitmap [modified] Pin
Anthony Mushrow26-Oct-07 1:11
professionalAnthony Mushrow26-Oct-07 1:11 
GeneralRe: Load and resize a bitmap Pin
Christian Graus26-Oct-07 11:47
protectorChristian Graus26-Oct-07 11:47 
AnswerRe: Load and resize a bitmap Pin
Luc Pattyn26-Oct-07 3:25
sitebuilderLuc Pattyn26-Oct-07 3:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.