C#http://forums.asp.net/37.aspx/1?C+Questions about using C# for ASP.NET developmentFri, 24 May 2013 10:37:04 -0400urn:uuid:00000000-0000-0000-0000-000000000037urn:uuid:00000000-0000-0000-0000-000005404957http://forums.asp.net/p/1909492/5404957.aspx/1?Generic+Methods+Generic Methods <p>Hey Developers ..</p> <p>I just want to write a code once to save records in multiple tables ... I want to implement Generic Methods .I have three .aspx pages where I require to save data in three different tables ...Please forward me complete steps. .please forward c# code only ..Thanks&nbsp;</p> 2013-05-25T09:59:17-04:002013-05-25T09:59:17.58-04:00urn:uuid:00000000-0000-0000-0000-000005404938http://forums.asp.net/p/1909485/5404938.aspx/1?Get+weeks+List+of+Current+month+in+c+dropdownlistGet weeks List of Current month in c# dropdownlist <p>Hi all,</p> <p>* I have task which I need to get number of weeks in current month and bind to dropdown-list</p> <p>* and in dropdownlist it should have date &amp; day of the week which starts and ends.Example as below the first week of the this may month starts on from (wednesday)05/01/2013 and ends with 05/01/2013(Sunday)</p> <p>(wednesday)05/01/2013 - 05/01/2013(Sunday)</p> <p>Can any one help me how can i solve this issue</p> 2013-05-25T09:04:51-04:002013-05-25T09:04:51.723-04:00urn:uuid:00000000-0000-0000-0000-000005404241http://forums.asp.net/p/1909297/5404241.aspx/1?A+boolean+parameter+Why+do+you+sometimes+have+to+use+required+false+A boolean parameter. Why do you sometimes have to use required: false? <p>Hi,</p> <p>whats the difference between using&nbsp;required: false and using false as a parameter?</p> <p>Thanks.</p> 2013-05-24T09:58:02-04:002013-05-24T09:58:02.737-04:00urn:uuid:00000000-0000-0000-0000-000005403227http://forums.asp.net/p/1909034/5403227.aspx/1?Why+Partial+Class+is+Used+Why Partial Class is Used? <p>What is useful purpose of partial class?</p> <p>Is it sort of class re-factoring?&nbsp;</p> 2013-05-23T10:39:30-04:002013-05-23T10:39:30.44-04:00urn:uuid:00000000-0000-0000-0000-000005403989http://forums.asp.net/p/1909233/5403989.aspx/1?How+I+can+return+the+ID+after+insert+a+record+into+a+database+Firebird+2+5+with+Linq+using+Visual+C+WPF+VS+2010How I can return the ID after insert a record into a database Firebird 2.5 with Linq? using Visual C # WPF VS 2010 <p><span class="hps">How</span> <span class="hps">I can</span> <span class="hps"> return the</span> <span class="hps">ID</span> <span class="hps">after</span> <span class="hps"> insert a record into</span> <span class="hps">a database</span> <span class="hps"> Firebird 2.5</span> <span class="hps">with</span> <span class="hps">Linq</span><span>?</span> <span class="hps">using</span> <span class="hps">Visual</span> <span class="hps"> C #</span> <span class="hps">WPF</span> <span class="hps">VS</span> <span class="hps"> 2010, a</span> <span class="hps">model</span> <span class="hps">already loaded in</span> <span class="hps">my project.</span></p> 2013-05-24T05:10:01-04:002013-05-24T05:10:01.93-04:00urn:uuid:00000000-0000-0000-0000-000005403791http://forums.asp.net/p/1909190/5403791.aspx/1?Change+the+format+of+am+email+address+C+Change the format of am email address C# <p><span class="detail"><span size="5" style="font-size:x-large">Hello all!<br> I have an email address like this, I am a user on a domain.<br> BGD.ORG\\some.name<br> <br> I would like to format it in C# to be this:<br> some.name@BGD.ORG<br> I am quite new to C# and any directio would be helpful. Thank you.</span></span></p> 2013-05-23T20:20:09-04:002013-05-23T20:20:09.5-04:00urn:uuid:00000000-0000-0000-0000-000005403590http://forums.asp.net/p/1909142/5403590.aspx/1?Export+to+pdf+and+emailExport to pdf and email <p>Hi All,</p> <p>I have a gridview from which I need to export data to pdf. I'm following the below way to achieve this</p> <pre class="prettyprint">dt = (DataTable)Session[&quot;dt&quot;]; //create dynamic gridview GridView dgDgrid = new GridView(); dgDgrid.AllowPaging = false; dgDgrid.DataSource = dt; //Create bound fields BoundField dgc_reqId = new BoundField(); dgc_reqId.DataField = &quot;Field1&quot;; dgc_reqId.HeaderText = &quot;Field1&quot;; dgDgrid.Columns.Add(dgc_reqId); BoundField dgc_expItem = new BoundField(); dgc_expItem.DataField = &quot;Field2&quot;; dgc_expItem.HeaderText = &quot;Field2&quot;; dgDgrid.Columns.Add(dgc_expItem); BoundField dgc_expDate = new BoundField(); dgc_expDate.DataField = &quot;Field3&quot;; dgc_expDate.HeaderText = &quot;Field3&quot;; dgDgrid.Columns.Add(dgc_expDate); BoundField dgc_fromDate = new BoundField(); dgc_fromDate.DataField = &quot;Field4&quot;; dgc_fromDate.HeaderText = &quot;Field4&quot;; dgDgrid.Columns.Add(dgc_fromDate); dgDgrid.AutoGenerateColumns = false; dgDgrid.DataBind(); dgDgrid.Caption = &quot;&lt;b&gt;Report&lt;/b&gt;&quot;; //Generate PDF file Response.ContentType = &quot;application/pdf&quot;; Response.AddHeader(&quot;content-disposition&quot;, &quot;attachment;filename= &quot; &#43; Session[&quot;username&quot;] &#43; &quot;_Report.pdf&quot;); Response.Cache.SetCacheability(HttpCacheability.NoCache); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); sw.WriteLine(dgDgrid.Caption); dgDgrid.RenderControl(hw); StringReader sr = new StringReader(sw.ToString()); Document pdfDoc = new Document(PageSize.A5, 10f, 10f, 10f, 0f); HTMLWorker htmlparser = new HTMLWorker(pdfDoc); PdfWriter.GetInstance(pdfDoc, Response.OutputStream); pdfDoc.Open(); pdfDoc.AddHeader(&quot;Head&quot;, &quot;Project Report&quot;); htmlparser.Parse(sr); pdfDoc.Close(); Response.Write(pdfDoc); Response.End();</pre> <p>Here instead of downloading the pdf i need to email to the user attaching the currently generated pdf..</p> <p>Any idea how to achieve this?</p> <p></p> <p>Appreciate your help.<br> <br> </p> 2013-05-23T15:32:16-04:002013-05-23T15:32:16.413-04:00urn:uuid:00000000-0000-0000-0000-000005402654http://forums.asp.net/p/1908901/5402654.aspx/1?Interface+Members+only+publicInterface Members only public <p>Why interface members are only public?? Why not protected or any other access specifiers we can use in interface members??</p> 2013-05-22T20:45:05-04:002013-05-22T20:45:05.99-04:00urn:uuid:00000000-0000-0000-0000-000005395451http://forums.asp.net/p/1906391/5395451.aspx/1?difference+between+class+variable+and+class+object+c+difference between class variable and class object c# <p>I am confused somebody tell me-</p> <p>what is difference between class variable and class object c#</p> <p>with example</p> <p></p> 2013-05-16T05:46:11-04:002013-05-16T05:46:11.433-04:00urn:uuid:00000000-0000-0000-0000-000005402174http://forums.asp.net/p/1908789/5402174.aspx/1?Abstract+generic+classAbstract generic class <p>I'm building an abstract class for my BLL, MyClass&lt;TKey, TItem&gt; where TKey is int or short in most cases and TItem is a local class.</p> <p>The class will include:</p> <p>- SortedList&lt;TKey, TItem&gt;</p> <p>- Typed TableAdapter from DAL</p> <p>- Typed DataTable from DAL</p> <p>- Update, Insert, Select methods - parameters for them change according to TItem</p> <p>How can this be implemented?</p> <p>Thank You.</p> <p></p> 2013-05-22T12:08:05-04:002013-05-22T12:08:05.707-04:00urn:uuid:00000000-0000-0000-0000-000005402117http://forums.asp.net/p/1908772/5402117.aspx/1?About+some+structures+in+my+codeAbout some structures in my code <p>Hi There;</p> <p>As a Java backgrounded programmer, I see some structure that it doesn't&nbsp; make sense to me. Colud you please explain it?</p> <p>Thanks in advance.</p> <pre class="prettyprint">protected NationalParkShopDataSet dsShop { get { return ((NationalParkShopDataSet)Session[&quot;__dsShop&quot;]); } set { Session[&quot;__dsShop&quot;] = value; } }</pre> <p><br> <br> </p> 2013-05-22T11:12:47-04:002013-05-22T11:12:47.553-04:00urn:uuid:00000000-0000-0000-0000-000005401273http://forums.asp.net/p/1908556/5401273.aspx/1?access+hotmail+calendar+events+C+access hotmail calendar events C# <p>how can i access hotmail calendar events using c#?</p> 2013-05-21T17:32:45-04:002013-05-21T17:32:45.747-04:00urn:uuid:00000000-0000-0000-0000-000005400803http://forums.asp.net/p/1908452/5400803.aspx/1?Error+CS0006+Metadata+file+System+Collections+dll+could+not+be+foundError CS0006: Metadata file 'System.Collections.dll' could not be found <p>I have a requirement were i need to create dynamic assembly at runtime. If i use simple addition function which retun interger sum then its working fine but when i use LINQ functionality inside my function then CompilerResults as error.</p> <p>I already add respective assembly references and do many work around but none of them works.</p> <p>Does anyone knows how to solve this issue. &nbsp;</p> <pre class="prettyprint">protected void Button4_Click(object sender, EventArgs e) { StringBuilder sb = new StringBuilder(); sb.Append(&quot; public class MyClass { &quot;); sb.AppendLine(); sb.Append(&quot; public MyClass(){ } &quot;); sb.AppendLine(); sb.Append(&quot; public List&lt;int&gt; GetLinq() &quot;); sb.AppendLine(); sb.Append(&quot; { &quot;); sb.AppendLine(); sb.Append(&quot; List&lt;int&gt; lst = new List&lt;int&gt; { 1,2,3};&quot;); sb.AppendLine(); sb.Append(&quot; var source = lst.AsQuerable(); &quot;); sb.AppendLine(); sb.Append(&quot; var obj = from i in source select i; &quot;); sb.AppendLine(); sb.Append(&quot; return obj.ToList&lt;int&gt;(); sb.AppendLine(); sb.Append(&quot; } &quot;); sb.AppendLine(); sb.Append(&quot; } &quot;); sb.AppendLine(); // string functionName = &quot;GetLinq&quot;; CodeDomProvider provider; string language = &quot;cs&quot;; Dictionary&lt;string, string&gt; compilerInfo = new Dictionary&lt;string, string&gt;(); compilerInfo.Add(&quot;CompilerVersion&quot;, &quot;v3.5&quot;); // Check for a provider corresponding to the input language. if (CodeDomProvider.IsDefinedLanguage(language)) { provider = new Microsoft.CSharp.CSharpCodeProvider(compilerInfo); CompilerInfo langCompilerInfo = CodeDomProvider.GetCompilerInfo(language); CompilerParameters langCompilerConfig = langCompilerInfo.CreateDefaultCompilerParameters(); langCompilerConfig.ReferencedAssemblies.Add(&quot;System.dll&quot;); langCompilerConfig.ReferencedAssemblies.Add(&quot;System.Core.dll&quot;); langCompilerConfig.ReferencedAssemblies.Add(&quot;System.Data.dll&quot;); langCompilerConfig.ReferencedAssemblies.Add(&quot;System.Xml.dll&quot;); langCompilerConfig.ReferencedAssemblies.Add(&quot;System.Collections.dll&quot;); langCompilerConfig.GenerateInMemory = true; langCompilerConfig.TreatWarningsAsErrors = false; langCompilerConfig.CompilerOptions = &quot;/optimize&quot;; // CompilerResults results = provider.CompileAssemblyFromSource(langCompilerConfig, sb.ToString()); if (results.Errors.Count &gt; 0) { Response.Write(&quot;Errors Occured&quot; &#43; results.Errors.Count); return; } else { Type dynamicType; dynamicType = results.CompiledAssembly.GetType(&quot;MyClass&quot;); MethodInfo method; method = dynamicType.GetMethod(functionName); var obj = method.Invoke(null, null); } } else { // Tell the user that the language provider was not found. Response.Write(&quot;There is no support for input language \&quot;&quot;&#43;language&#43;&quot;\&quot;.&quot;); //return null; } }</pre> <p><br> </p> 2013-05-21T10:10:28-04:002013-05-21T10:10:28.89-04:00urn:uuid:00000000-0000-0000-0000-000005401503http://forums.asp.net/p/1908617/5401503.aspx/1?Declaring+Readonly+inside+a+Method+of+a+ClassDeclaring Readonly inside a Method of a Class <p>Hi everyone,</p> <p>I have created a class and there is one public method in the class. Can I create a readonly field inside that method ? I was trying to that but was getting an error that &quot;Modifier is not valid for this item&quot;.</p> <p>But if I create constant then there is no error. Can you please guide me why its happening ?</p> <p></p> <p>Thanks and Regards</p> <p>Ritesh</p> 2013-05-22T01:14:10-04:002013-05-22T01:14:10.04-04:00urn:uuid:00000000-0000-0000-0000-000005400685http://forums.asp.net/p/1908434/5400685.aspx/1?linq+to+fetch+index+of+string+arraylinq to fetch index of string array <p>var _Col_Name_lst = (from DataColumn x in _hdr[0].Table.Columns<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; select x.ColumnName).ToArray();</p> <p></p> <p>_Col_Name_lst&nbsp; ----- This has a collection of string array</p> <p>like</p> <p>0&nbsp; - EMl</p> <p>1&nbsp; - AZEER</p> <p>2 -&nbsp; VISTA</p> <p></p> <p>--------</p> <p>Here in above collection, i require array index of EMI or AZEER or VISTA whichever i pass to a linq.</p> <p>so using linq on above collection --- &quot;_Col_Name_lst &quot;</p> <p>i require index of any values EMI or AZEER or VISTA whichever i pass</p> <p></p> <p>&nbsp;&nbsp;&nbsp; var _Col_Name = from col in _Col_Name_lst<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; where col == (&quot;EML_power&quot;)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; select col.IndexOf(&quot;EML_power&quot;);</p> 2013-05-21T08:55:54-04:002013-05-21T08:55:54.713-04:00urn:uuid:00000000-0000-0000-0000-000005401309http://forums.asp.net/p/1908570/5401309.aspx/1?Read+a+Remote+Html+file+in+C+Read a Remote Html file in C# <p>Hi,&nbsp;</p> <p>I want to read the HTML which exists on a server using c# but it shows an error of&nbsp;</p> <ol> <li>URI formats are not supported </li><li>The file's path are not supported </li></ol> <p>i've tried with the following code</p> <pre class="prettyprint">using (FileStream fs = new FileStream(&quot;http://192.168.0.1/MySite/Default.html&quot;, FileMode.Open))</pre> <pre class="prettyprint"> using (FileStream fs = new FileStream(@"192.168.0.1\D:\Web\www\MySite\Default.html", FileMode.Open)) { if (fs.Length == 0) { } else { using (StreamReader sr = new StreamReader(fs)) { for (int i = 0; i &lt; 2; i++) { string temp = ""; while ((temp = sr.ReadLine()) != null) { status[i] = temp; } } } } }</pre> <p>What is the correct way?</p> <p>Tell me please</p> <p>Thanx in Advance</p> 2013-05-21T18:08:58-04:002013-05-21T18:08:58.94-04:00urn:uuid:00000000-0000-0000-0000-000005401201http://forums.asp.net/p/1908532/5401201.aspx/1?Query+ProblemQuery Problem <p>Dear All,</p> <p>i am trying to compare a Sessions list with another list after splitting with comma in where command and unable to do that, here is the query.&nbsp;</p> <pre class="prettyprint">public static List&lt;CorporatesInvoice&gt; SelectInvoicesForCorporates(int CorporateID, int CenterID, List&lt;int&gt; SessionID, LanguageEnum languageParam) { ELSPortalDataContext db = new ELSPortalDataContext(); var obj = (from r in db.SessionClassStudents join j in db.CorporateInvoices.ToList().<strong>Where(o =&gt; o.ObjectID.Split(',').ToList().All(c =&gt; SessionID.Contains(Convert.ToInt32(c))))</strong> on CorporateID equals j.CorporateID select new CorporatesInvoice { }</pre> <p><strong>lets say List of SessionID is [47,48,49] and string ObjectID in db is like 48,49. &nbsp;</strong>if SessionID is matching completely with object ID only then that record should return i.e if List of Session ID have 45,44 and ObjectID in db also have the same 45,44 -&gt; this could be in reverse order</p> <p>kindly take a look especially at highlited code and let me know what is wrong and how to make it working? it says &quot;<strong>Local sequence cannot be used in LINQ to SQL implementations of query operators except the Contains operator</strong>&quot;</p> <p>Thanks alot.</p> <p></p> 2013-05-21T15:40:29-04:002013-05-21T15:40:29.587-04:00urn:uuid:00000000-0000-0000-0000-000005401131http://forums.asp.net/p/1908515/5401131.aspx/1?Help+needed+in+LINQ+queryHelp needed in LINQ query <p>Hi Guys,</p> <p>&nbsp;i have a problem in a query, i am trying to split a string with comma and then i am trying to compare all splitted values with the list of sessions, here is the code&nbsp;</p> <pre class="prettyprint">public static CorporateInvoice SelectInvoiceByCorporateAndSession(int CorporateID, List&lt;int&gt; SessionID) { ELSPortalDataContext db = new ELSPortalDataContext(); return db.CorporateInvoices.SingleOrDefault(o =&gt; o.CorporateID == CorporateID &amp;&amp; o.ObjectID.Split(',').ToList().Any(c =&gt; SessionID.Select(k =&gt; k.ToString()).Contains(c))); }</pre> <p></p> <p>i am unable to do and getting error &quot;<em style="font-size:1.5em">Method 'System.String[] Split(Char[])' has no supported translation to SQ</em><span style="font-size:13px">&quot;</span></p> <p>Please help.</p> <p></p> <p>Thanks</p> 2013-05-21T14:22:35-04:002013-05-21T14:22:35.867-04:00urn:uuid:00000000-0000-0000-0000-000002589359http://forums.asp.net/p/1312849/2589359.aspx/1?problem+converting+VB+to+C+problem converting VB to C# <p>HI Guys,</p> <p>I am writing server side validation in c# which was in VB</p> <p>the code in VB is<br> </p> <pre class="divscript">If Not IsNumeric(Args.Values(&quot;BookQty&quot;)) Then<br> Args.Cancel = True<br> EditMSG.Text = &quot;&amp;bull; Quantity is not numeric&quot;</pre> <pre class="divscript">If Args.Values(&quot;BookQty&quot;) &lt; 0 Then<br> Args.Cancel = True<br> EditMSG.Text = &quot;&amp;bull; Quantity is out of range&quot;<br> End If&nbsp;</pre> <pre class="divscript">the code I converted to c# using converter</pre> <pre class="divscript">These are two errors<br> <br></pre> <pre class="divscript">if (!IsNumeric(Args.NewValues[&quot;BookQty&quot;]))<br> {<br> Args.Cancel = true;<br> EditMSG.Text = &quot;•Quantity is not numeric&quot;; </pre> <pre class="divscript"><br></pre> <pre class="divscript">The name 'IsNumeric' does not exist in the current context </pre> <pre class="divscript"> if ((Args.Values[&quot;BookQty&quot;] &lt; 0))<br> {<br> Args.Cancel = true;<br> EditMSG.Text = &quot;• Quantity is out of range&quot;;<br> }<br></pre> <pre class="divscript">Operator '&lt;' cannot be applied to operands of type 'object' and 'int' </pre> <pre class="divscript">can anybody please help me.&nbsp;</pre> 2008-08-29T16:11:06-04:002008-08-29T16:11:06.273-04:00urn:uuid:00000000-0000-0000-0000-000005399412http://forums.asp.net/p/1908140/5399412.aspx/1?Find+time+difference+between+01+30pm+to+11+30pm+Using+c+netFind time difference between 01.30pm to 11.30pm Using c#.net <p>Ho&nbsp; to find out the Time Difference ( Difference will include HH:MM) Between the 01.30pm to 11.30pm using the C#.net ?</p> 2013-05-20T07:23:23-04:002013-05-20T07:23:23.4-04:00