|
Hi,
Thanks for your reply,
if i use script manager in my content page's
Ajax Collapsible panel is not working that is the problem,
I tried by removing master page and added script manager seperately in my
page then it's working fine,
Hope this is clear for you!!
|
|
|
|
|
Hi
I have a grid with any number of rows. Each row has a picturebox drawn next to it.
The pictureboxes have context menu's assigned to them (5 menuitems).
Problem is, selecting an item from the contextmenu makes sender the contextmenu, so I don't know which row's picture box was right-clicked.
My code looks like this at the moment.
Declarations:
private ContextMenu[] mnuLamps;
I have a routine which creates the contextmenus's:
mnuLamps = null;
mnuLamps = new ContextMenu[dsSummary.Tables[0].Rows.Count];
for (int i = 0; i < dsSummary.Tables[0].Rows.Count; i++)
{
mnuLamps[i] = new ContextMenu();
mnuLamps[i].MenuItems.Add(new MenuItem());
mnuLamps[i].MenuItems[0].Text = "Receive";
mnuLamps[i].MenuItems[0].Click += new EventHandler(ReceiveSelected);
...
mnuLamps[i].MenuItems.Add(new MenuItem());
mnuLamps[i].MenuItems[4].Text = "Retract";
mnuLamps[i].MenuItems[4].Click += new EventHandler(RetractSelected);
}
When the pictureboxes are added to the form I have:
for (int i = 0; i < dsSummary.Tables[0].Rows.Count; i++)
{
...
picBox[i].ContextMenu = mnuLamps[i];
...
}
I then have ReceiveSelected, RetractSelected etc as:
private void ReceiveSlecetd(object sender, EventArgs e)
sender is of course menuitem, so I don't know which row it was.
I have thought of using
private void ReceiveSelected(object sender, EventArgs e, int TheRow)
and
mnuLamps[i].MenuItems[0].Click += new EventHandler(ReceiveSelected(mnuLamps[i], EventArgs, [i]);
so that I have access to the row, but I am having trouble doing the EventArgs and I am not sure I can use this code fiddling.
Thanks,
Nigel
|
|
|
|
|
Hi,
as you have separate ContextMenu objects for all the PictureBoxes here are two things you could do:
1.
store the PictureBox reference inside the ContextMenu.Tag
the Tag property can hold any object or value you choose, and isn't used by Windows, .NET or GDI; a lot of Controls have a Tag property, when available it is there for your convenience.
2.
Maintain a Dictionary mapping ContextMenu objects to PictureBox objects.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hi Experts
How Make Paging of data in Datagridview.in C#.Net.
Dinesh Sharma
Thank U
|
|
|
|
|
Searching the articles before posting may help at times. Look I found something here[^].
|
|
|
|
|
Hi, I created a class library and wrote a function with the try {} catch { throw ;} finally {} manner. However I am not doing anything in the catch block, only throwing the exception. I am handling the exception the UI layer which is using that class library. I want to know the best approach to write the try block. If I use only try {} finally {} without catch block, does it good ?
Pankaj
|
|
|
|
|
Are you even allowed to skip catch? I dont think so.
If the method calling the Class library method handles the exceptions(even for the class library methods), you can avoid try-catch block in the class library method.
|
|
|
|
|
I can not avoid the try catch finally in my class library. Because I am doing file operation in the class library, that's why I have to open and working on the files and in the finally block I am closing the writer/reader/file.
Pankaj
|
|
|
|
|
Hi,
From the C# 2.0 standard:
There are three possible forms of try statements:
• A try block followed by one or more catch blocks.
• A try block followed by a finally block.
• A try block followed by one or more catch blocks followed by a finally block.
Alan.
|
|
|
|
|
You can use try/finally without the catch, but you have to think about why you are doing this. As you're not catching exceptions at the level that they are being thrown, you are storing up a lot of work for the higher levels. By this, I mean that you could catch the exception and do something meaningful with it, rather than relying on the UI reporting that there was an error.
For instance, we have a library that catches an error where the SqlConnection has become unavailable, and (in the appropriate catch), reconnects the SqlConnection before it attempts to process the SQL again.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
I do not want to use the try catch finally in the class library, however I am doing file operations in the class library. I open/read/write the file with the stream reader/writer object and have to close that reader/writer in the finally block. If any error occurs during the read/write operation then reader must be close, that's why I have to use the finally block to close the reader. Here is the code
public string ReadXmlNodeValue(string fileName, string xmlPath)
{
string retValue = "";
StreamReader sr = null;
XmlDocument doc = new XmlDocument();
try
{
sr = new StreamReader(fileName, Encoding.UTF8);
doc.Load(sr);
XmlNode element = doc.SelectSingleNode(xmlPath);
retValue = element.InnerText;
}
catch
{
throw;
}
finally
{
sr.Close();
sr = null;
doc = null;
}
return retValue;
}
Can I write the above code without try catch finally block and it will close the reader if any error is generated during the process ?
Pankaj
|
|
|
|
|
Pankaj Saha wrote: Can I write the above code without try catch finally block and it will close the reader if any error is generated during the process ?
If you mean, can you dispense with try/finally as well, then you should not. The finally portion will close the reader, regardless as to whether or not an exception is thrown. As StreamReader is a disposable object though, you could always rewrite this with:
using(StreamReader sr = new StreamReader(fileName, Encoding.UTF8))
{
} When StreamReader is disposed the stream is closed (if it is open).
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Hi,
a try block accepts one or more catch blocks and one or no finally blocks;
When there is a finally block, the catch blocks can be left out.
A catch block that only throws does not make any sense; just throw it out!
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
|
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I am developing an application in C# and using richtextbox. After formatting the text when i select all the text it gives exception given below:
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
at RichTextEditor.Editor.ucEditor.rtbDoc_SelectionChanged(Object sender, EventArgs e) in E:\MDCENTERWINAPP\Editor\ucEditor.cs:line 841
at System.Windows.Forms.RichTextBox.OnSelectionChanged(EventArgs e)
at System.Windows.Forms.RichTextBox.WmSelectionChange(SELCHANGE selChange)
at System.Windows.Forms.RichTextBox.WmReflectNotify(Message& m)
at System.Windows.Forms.RichTextBox.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Any Suggestion...............
Do good and have good.
|
|
|
|
|
Hi,
The message gives the location of the exception causing statement in the source code.
Silent Eagle wrote: System.NullReferenceException: Object reference not set to an instance of an object.
at RichTextEditor.Editor.ucEditor.rtbDoc_SelectionChanged(Object sender, EventArgs e) in E:\MDCENTERWINAPP\Editor\ucEditor.cs:line 841
If the error on line 841 is not obvious, set a breakpoint there and investigate further with the debugger.
Alan.
|
|
|
|
|
Hi
as Alan said, look at line 841.
Read the Exception text, it is there to help you. Look in particular to the first line that mentions one of your filenames, and a line number.
And tell Visual Studio to always show line numbers in edit windows (menu Tools/Options/TextEditor/AllLanguages...).
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
hello
In ASP.NET, we can use Report View control to access reports on a Reporting Service instance.
Now,
(1) if I want default PDF format - i.e. without having use to click that "Export to PDF" button in reporting viewer command bar...?
(2) What if some of my own .NET process (MyReportServer.exe) wants to call SQL/Reporting Service directly to export PDF? How do I do that?
Thanks
dev
|
|
|
|
|
how to get only time from this string
string strtime="Tue-07-Jul-2009 12:00 PM";
|
|
|
|
|
|
Set the format of time in which you want to get it.
strtime.format("dd/MM/yyyy");
If you can think then I Can.
|
|
|
|
|
Try like
(1)
string strtime = "Tue-07-Jul-2009 12:00 PM";
strtime = strtime.Substring(strtime.IndexOf(" ")+1,strtime.Length-strtime.IndexOf(" ")-1);
(2)
DateTime dt3=DateTime.Parse(strtime);
strtime= dt3.ToShortTimeString();
himanshu
|
|
|
|
|
string strtime = "Tue-07-Jul-2009 12:00 PM";
string format = "ddd-dd-MMM-yyyy hh:mm tt";
CultureInfo formatProvider = new CultureInfo("en-US");
DateTime dt = DateTime.ParseExact(strtime, format, formatProvider);
Console.WriteLine(dt.ToString("hh:mm:ss tt"));
|
|
|
|
|
Hi Guys,
I tried a lot to figure out how to skip writin onto a particular excel cell using C#, but couldnt get the proper logic.
my eg:
*Team Leader (required) abcxyz User1 user2
Customer Interface Focal dfgidf user23 user3*
each of the names above has to be in a particular cell... but in the excel template, first cell (Team Leader (required)) is readonly, so i cant write into that cell, so my final excel sheet should show
abcxyz User1 user2
Customer Interface Focal dfgidf user23 user3.....
.....
i tried various logics for this... please see the code below
1. Microsoft.Office.Interop.Excel.Workbook SelWorkBook = excelappln1.Workbooks.Open(curfile,
0, false, 5, "", "", false, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "", true, false, 0, false, false, false);
Microsoft.Office.Interop.Excel.Sheets excelSheets = SelWorkBook.Worksheets;
Microsoft.Office.Interop.Excel.Worksheet excelworksheet = (Microsoft.Office.Interop.Excel.Worksheet)excelSheets.get_Item(CurSheetName);
Microsoft.Office.Interop.Excel.Range excelRange = excelworksheet.UsedRange;
if ((!excelworksheet.Cells[CurTaskNode.DATA_MIN_ROW + minRow, CurTaskNode.DATA_MIN_COL + minCol]).Locked)
{
// Assigning the Value from reader to the particular cell in excel sheet excelworksheet.Cells[CurTaskNode.DATA_MIN_ROW + minRow, CurTaskNode.DATA_MIN_COL + minCol] = values[iValueIndex];
iValueIndex++;
}
but the error shows, in the if statement
Error 1 Operator '!' cannot be applied to operand of type 'object'
so, please say how to handle this case.
Thanks
Ramm
|
|
|
|