|
So it can't be done then? Nuts.
Incidentally how do you convert If searchString Like "p#" Then
I've written a strLeft function to do what VB6 did. It works well enough, I could change it and check for if (functionClass.strLeft(searchString,4) == "page") .
Thanks btw.
Ninja (the Nerd)
Confused? You will be...
|
|
|
|
|
You can use searchString.StartsWith(p)
-^-^-^-^-^-
no risk no funk ................... please vote ------>
|
|
|
|
|
C# doesn't have the same concept behind switch statements as VB. It can be done, but you would need to list all of the values between "x" and "y". The "is > z" can't be represented by a case, however.
Your best bet would be to do either rework your logic so you can use the switch, which would probably mean defining more specific cases and using the default case to handle the "is > z" condition, or to use if/else blocks.
|
|
|
|
|
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
|
|
|
|
|
b>You can raise server side event when the mouse over the imagebutton.
function Show()
{
document.getElementById('<%=ImageButton1.ClientID%>').click();
}
ServerSide code
protected void Page_Load(object sender, EventArgs e)
{
ImageButton1.Attributes.Add("onmouseover", "Show();");
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
// Write your event handler...
}
Shanmugam R
|
|
|
|
|
I want to be able to raise an event without actually clicking on the image buttons - which is why I am including buttons that do nothing but raise the event when the image button is hovered over.
-- I've now managed to highlight the node by hovering over the image button using the line of code from the previous post (below).
document.getElementById('<%=btnMouseOutCheat.ClientID %>').click();
Only as before, the mouseover event is continually raised when this happens - when I only really want to fire the event once on mouseover and again with mouseout.
Any ideas anyone?
-- modified at 9:16 Friday 26th October, 2007
|
|
|
|
|
You have to use ajax then. You don't have any other option.
Ben
|
|
|
|
|
The whole DataList control (ascx file) is enclosed in an UpdatePanel in the parent control - and I am having the problem that I already mentioned.
Do you mean that I need to use an ashx handler? If so, any ideas how I might go about writing that?
thanks,
Dave
|
|
|
|
|
Hi
I m getting this error while Grabbing the frame n sending it using sockets to other application.
"Unable to cast COM object of type 'System.__ComObject' to interface type...... This Operation failed because the QueryInterface call on the COM component for the interface with IDD'{6B652FFF-11FE-4FCE-92AD-0266B5D7C78F}' failed due to following error: No such interface supported(Exception from HRESULT:0x80004002(E_NOINTERFACE))"
Plz try to help me out ASAP.
Shanzay
|
|
|
|
|
Hi,
i m using a datagridview to show and update data from sql server. everything works ok, bud when i change a row and click on save changes, it does not update the datasource. to breng changes in the database i have to go first on a other row ( by clicking on a other row) and then klik on save changes, then it works. anyone any idea ?
|
|
|
|
|
Djavid j wrote: when i change a row and click on save changes, it does not update the datasource.
You have to add in code to update the database.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Anyone please suggest me that.........
When we send multiple PDF documents from a loop for printing using Process class, the printing is not taking place in the order of documents created.
Please suggest me that how to solve this problem using C#.NET.
With Regards
Tapan
|
|
|
|
|
I don't know if it is possible to change the order of the print jobs without digging deep into the internals of Windows...
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hi all,
I am using web application to request some infomation to the valid gateway and get the response. But in some time if we request the invalid gateway it wont response. So the application does not do anything without the response.
So I planned to use the thread and timer concept. If I put the function in thread and used the timer concept. In the windows application i did the same using the thread and the timer tick. I dont know how to implement in the web application. If anybody knows please give me ur suggestions.
Regards
Arunselvaguru.A
|
|
|
|
|
Threading and timers make no sense in an ASP.NET app, where your code is disconnected from the UI, and runs to create a new page every time a postback occurs. The code isn't always running, it's not running at all when the user is viewing a page, so what use is a thread ? For the same reason, why use a timer to slow down the time it takes for the user to see the next page ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Obviously, I know how to load an image from a memory stream ( which is what I have on hand in this instance ), and I know how to resize it. What I want to know is, if I have a memory stream that represents a 4092x4092 PNG, does any method exist where by I can create a 1024x1024 ( for example ) copy of this image without having to have enough memory to hold the full size image as part of the process ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
As in when you load it, you don't want to have to load the whole thing, just load a 1/16th of the data to arrive at a new image?
[This is going to sound like a dodgy VB inspired workaround]
I would read in X pixels where X is dependent on the new size of the image.
Then average these to arrive at one pixel.
This continues until the end of the line, then you could repeat this X times, to give a few lines from the top of the image.
Then you repeat the process downwards, to arrive at a single row shrunk from the first X rows of the image.
Then repeat until the end of the stream.
If it works, mail me, I like a surprise now and then.
Ninja (the Nerd)
Confused? You will be...
|
|
|
|
|
Yeah, that's the sort of approach I was hoping is possible, the issue is that the image is a PNG. Once I have pixels I can examine, I have a bitmap in memory and my purpose has already not been achieved ( I don't know how to decompress a png one line at a time ).
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
The easiest way i can think of to resize an image, is to use graphics.drawimage
You'll have to calculate the ratio between the old size, and the new size. Then use the draw method to draw from 0,0,500,500 for example, into a new bitmap to the rectangle 0,0,250,250 That should resize the image. Then save this small portion in to a temp file somewhere. Then, move onto the next portion.
Once you've finished with the large image, you can get rid of it. Then, create a new bitmap of the desired size, and start opening up your temp files, and rebuild the full image.
Of course it would be quicker to sacrifice memory, and just copy the image directly. But if you have 32-bit images with huge sizes like 4092*4092, then it is gonna take up alot of space isn't it... infact almost 50MB
-- modified at 7:25 Friday 26th October, 2007
Okay, as for the original image, the problem is the header information, and the way the data is stored. For a regular bitmap, you could read the header information, find the size (width, height) and bit-depth of the image, then just start reading off the bytes because there's no compression.
As for something more like a png, it may be difficult to do because of the way the information is stored, and well, i havn't come up with much.
My current favourite word is: Waffle
Cheese is still good though.
|
|
|
|
|
Yeah, you got to my issue. I can't do it with a PNG.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi Christian,
I don't expect there is a general solution, resizing an image file without loading the
entire file that is. For a specific format, you could write your own file decoder.
The PNG format consists of a lot of "chuncks", identified by a type field. There will
be a header (IHDR), some more attributes, then a number of data chunks (IDAT).
I don't expect the IDAT chunks to synchronize with scanlines though.
To get what you want, I would split the input image in "bands" (an arbitrary number of
consecutive scanlines), then do width reduction on each band, assemble the results into
a new image (graphics-form-bitmpa and DrawImage), then do the vertical reduction on the
image level.
If you try to do non-integer vertical reduction on bands you are bound to get artefacts,
such as moire, where the bands touch.
With this approach the overall memory footprint would be reduced by a factor of almost 4,
your linear scale factor that is.
Remark: if your scale factor were an exact integer (it is very close to 4, maybe 1023*1023
would be OK?) I would consider a direct two-dimensional rescale avoiding the input image
footprint altogether.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Sounds like a sensible solution. Sadly I have 24 hours to impliment this and other changes, not sure I can work out the PNG format in that time ( I also have to support JPG ).
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
As you are well aware, JPEG is a more complex format. I only scratched the surface of
that one!
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
I've got an application that needs to create vitual networking
in there, there are node get routing table in the fewtime
when routing table is convergence
but I've got diffcult, I hope give hepl!
Thanks a lot!
|
|
|
|
|
Looks to me like ths is your homework. What problems do you have ? Where are you stuck ? What have you already achieved ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|