C#

91K

Solutions

32

Articles & Videos

24K

Contributors

C# is an object-oriented programming language created in conjunction with Microsoft’s .NET framework. Compilation is usually done into the Microsoft Intermediate Language (MSIL), which is then JIT-compiled to native code (and cached) during execution in the Common Language Runtime (CLR).

Share tech news, updates, or what's on your mind.

Sign up to Post

I need to access the registry in my .NET program I am writing and need to know if I reference this registry entry:

Computer\HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Jet\4.0\Engines\Text

it will not break if the code is running on a 32 bit system.
0
Free Tool: SSL Checker
LVL 8
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

I have been tasked to build an online audit questionnaire/survey. I am fairly new to asp.net. I want to create the questions and server controls dynamically with data from sql server. For each questions I will need to dynamically create two  (Yes/No) radio buttons. Any help would be greatly appreciated. I am using asp.net forms.
0
Hi Experts,

This is my program. I am using some private variable to hold the values. Then I am using them through out the program. I want to know is it the right way to do or I should keep them in the session variable and use them. I am curious to know that when many people access the same web page are these variables going to create problem or change the values.  I am using ASP.net and VB.net.

Thanks in advance.


Partial Class EditCustomerOrder
    Inherits System.Web.UI.Page
    Private Shared Calling_Form As String
    Private Shared CustomerID As Integer
    Private Shared LocationID As Integer
    Private Shared MenuOrderDate As DateTime
   
    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
        If Not IsPostBack Then
            Calling_Form = Request.QueryString("Calling_Form")
       
            If Session("EditCustOrder_Calling_Form") Is Nothing = False Then
                Calling_Form = Session("EditCustOrder_Calling_Form")
            Else
                Calling_Form = Request.QueryString("Calling_Form")
            End If

            If Session("EditCustOrder_MenuOrderDate") Is Nothing = False Then
                MenuOrderDate = Session("EditCustOrder_MenuOrderDate")
            Else
                MenuOrderDate = Request.QueryString("MenuDate")
            End If
0
Hi there
I have a WebGrid that I am populating with columns via the controller since I need the columns to change based on certain user selections. One of the columns is a checkbox and it should show as checked if the value I pass it is true, unchecked if false and disabled if null. At the moment I'm battling to create a condition that checks and unchecks the correct values. It is currently checking all or none.

Any assistance will be appreciated. Thanks in advance.

--My Grid
@grid.GetHtml(tableStyle: "table",
                      alternatingRowStyle: "alternate",
                      selectedRowStyle: "selected",
                      headerStyle: "header",
                      columns: ViewBag.Columns
                     )

--populated from controller. Status is my bool field
List<WebGridColumn> columns = new List<WebGridColumn>();
columns.Add(new WebGridColumn() { Format = (item) => { return new HtmlString(string.Format("<input id = '{0}' name = '{0}' class='box' type = 'checkbox' {1} == 'true' ? checked : '' value ='{1}') />", item.Id, item.Status)); } });
ViewBag.Columns = columns;
0
I need a query using which i can hide the details of Products not selected while shopping..for eg suppose we have 5 products option to buy and we choose only 2 out of 5, is there any sql-query or method(Repeaters,data list..etc) using which we can hide the item details not selected..using asp.net c#
0
I am using lotus notes to send email in .net application using c#. I am able to send mails from this application while i run this in my local host. But the thing is when host the application in local IIS server i am not able to send mails.
 I am getting the following error.
Notes error: Notes shared login failed with this ID file.
Please tell me why i am getting this error after hosting the application.
0
I want to add categories but I have this error
Here Is the source code
Line 70:                                            <asp:DataList ID ="dd" runat="server">
Line 71:                                             <ItemTemplate>
Line 72:                                                 <li><a href="#Events.aspx?type=<%#Eval("EventTypeName") %>"><%#Eval("EventTypeName") %></a></li>
Line 73:                                                </ItemTemplate>  
Line 74:                                             </asp:DataList>    

Open in new window

Code behind
 
con.Open();
        SqlCommand cmd = con.CreateCommand();

        if (Request.QueryString["type"] == null)
        {
            cmd.CommandText = "SELECT * FROM EventDetail";
        }
        else
        {
            cmd.CommandText = "SELECT * FROM EventDetail WHERE EventType_ID= '" + Request.QueryString["type"].ToString() + "' ";
        }

        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataTable dt = new DataTable();
        da.Fill(dt);
        dd.DataSource = dt;
        dd.DataBind();
        con.Close();

Open in new window


I have 2 tables
1. Event Type ( EventType_ID, EventTypeName )
2. EventDetail (EventDetail_ID, EventType_ID, eventDetailName....)
0
Can anyone recommend a .Net Kafka library?


thanks,

Rick
0
I would like to take this code and have it be reused for different stored procedures. This section of code would be called for each the the button on the form below. I have all the datatable, dbcommand, executenonquery, executescalar all in one c# class and call them when I need them I need to do this for the dataset code below

String connString = “”;

string sql = “select” – I would like to use a procedure so I can use the code in more than one place.

// create connection
Sqlconnection conn = new sqlconnection(connstring);

Try
{
Conn.open();

Sqldataadapter da = new sqldataapapter(sql, conn);

Dataset ds = new dataset();

Da.fill(ds, “”);
 
(would like to return ds.table
}
Catch
{
}
Finally
{
Conn.close();
0
My C# application is showing ominous behaviour.

The application is working perfectly fine for a specific Installation. But it's giving me this exception in another..
- SqlDataAdapter.Fill - Timeout expired.  The timeout period elapsed Prior to executing the query or the Server is not responding.

I've been searching all day for a solution and cant find anything helpful.

The c# Code is

            DataTable dt = new DataTable(tableName);
            try
            {
                using (SqlDataAdapter da = new SqlDataAdapter(SqlQuery, conn))
                {
                    Console.Write(SqlQuery);
                    da.Fill(dt);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("Foo String there is nothing good Happening {0}", ex.ToString()));
            }

Open in new window


The SQL is : SELECT * FROM FooTable WHERE ColumnA=0 and ColumnB='15'

Every Google post I've been looking at is about "increase your command timeout". Which makes me almost give up hope.

The same SQL in SSMS Returns only 1 row and I've seriously no idea what is going on.

I've attached a Debugger to the process and can definitely say the code is reaching the Console.Write as a breakpoint.
The exception is thrown at the fill method line.

I'm highly thankful for any responses.
0
Instantly Create Instructional Tutorials
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Hi Experts,

How to create a public variable which can be used only in the form. Suppose I have form1.aspx. How can I define a public variable which can be used only in form1 .no other form should able to access it.
0
How can I validate address using API  in C# or any batch process?
0
I have this code

public ActionResult GRIDPRINTS_Read(int woid, [DataSourceRequest]DataSourceRequest request)
        {
            IQueryable<GRIDPRINTS> gridprints = db.GRIDPRINTS;
            DataSourceResult result = gridprints.ToDataSourceResult(request, c => new GRIDPRINTS
            {
                WOID = c.WOID,
                GRIDPRTID = c.GRIDPRTID,
                GRIDID = c.GRIDID,
                MAPNAME = c.MAPNAME,
                SCALE = c.SCALE,
                PAGENUMBER = c.PAGENUMBER,
                ERRORS = c.ERRORS,
                STATUS = c.STATUS,
                NOTIFICATION = c.NOTIFICATION
            });

            return Json(result, JsonRequestBehavior.AllowGet);
        }

Open in new window


IT works fine Except I want to pass the woid to a where clause in the results.  So I added this line

.where(c.WOID==woid)    

public ActionResult GRIDPRINTS_Read(int woid, [DataSourceRequest]DataSourceRequest request)
        {
            IQueryable<GRIDPRINTS> gridprints = db.GRIDPRINTS;
            DataSourceResult result = gridprints.ToDataSourceResult(request, c => new GRIDPRINTS
            {
                WOID = c.WOID,
                GRIDPRTID = c.GRIDPRTID,
                GRIDID = c.GRIDID,
                MAPNAME = c.MAPNAME,
                SCALE = c.SCALE,
                PAGENUMBER = c.PAGENUMBER,
                ERRORS = c.ERRORS,
                STATUS = c.STATUS,
                NOTIFICATION = c.NOTIFICATION

             .where(c.WOID==woid)   

            });

            return Json(result, JsonRequestBehavior.AllowGet);
        }

Open in new window


It is failing with unknown method "where of string"  I am sure it is something simple stupid but after an hour of trying everything I am turning to the experts.
0
I'm new to Entity Framework and looking to move future development of an existing application in that direction.  Previously the development has been 'traditional' with VB, Winforms and SQL DataAdapters.  Looking forward, I'll be moving to C# with EF6 (or EF Core).  I'm currently working out how best to do this.  

To minimise impact on end users, I need the new forms I develop to work the same way as they always have.  In the past, for a data object neededing validation, I would handle the .validating event of the Control to which the data was bound and, if validation failed, display a messagebox to the user, set e.cancel=True and get them to try again.

That way, the validation code is in the Client Side  (the view).  In future I want it on the Object Model so that I can use the same validation for potential future development on other platforms (e.g web access).

I've read a lot about this and it doesn't seem to be the way validation works on EF.  Here's where I am.

I have a 'Schedule' data object in EF that has a field / property for Interval_Mins, which is an Integer value representing Minutes.  I want to ensure this value is between 1 and 59 (for example).

I know about the Range DataAnnotation but I want to do this in code in case I require some validation more complex that DataAnnotation allows (also I'm new to DataAnnotation so not clear on it's limitations - let me know if that's the better approach).

So, in my partial class for my 'Schedule' object I …
0
After clicking the type, it still shows all the items!
source code
   <asp:DataList ID ="dd" runat="server">
                                                <ItemTemplate>
                                                <li><a href="#Events.aspx?type=<%#Eval("EventTypeName") %>"><%#Eval("EventTypeName") %></a></li>
                                               </ItemTemplate>
                                            </asp:DataList>

code behind
 con.Open();
        SqlCommand cmd = con.CreateCommand();
        cmd.CommandType = CommandType.Text;

        if (Request.QueryString["type"] == null)
        {
            cmd.CommandText = "select * from EventDetail";
        }
        else
        {
            cmd.CommandText = "select * from EventDetail where EventTypeID= '"+ Request.QueryString["type"].ToString()  + "' ";
        }

        cmd.CommandText = "select * from EventType";
        cmd.ExecuteNonQuery();
        DataTable dt = new DataTable();
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        da.Fill(dt);
        dd.DataSource = dt;
        dd.DataBind();
        con.Close();

my two tables
1. EventDetail (EventDetail_ID, EventTypeID, eventDetailName, eventDate......)
2. EventType (EventType_ID, EventTypeName)
0
How can I convert

Example

32 to 0x20
 
A to 0x41

96 to 0x600x000x000x00

65736 to 0xC80x000x010x00

and back again.
0
I am in need of getting content of this page . the tracking Details. Any solution.

http://www.delhivery.com/track/package/1356910022971
0
After I added a sidebar and repositioned my items I had this error!

Codes from the source
            <tr>
                 <td>
                    <div class="col-sm-4">
                         <div class="thumbnail bg-grey text-center">
                             <h2>$14</h2>
                             <p>Basic License</p>
                             <a href="#" class="btn btn-success" role="button">Buy Now</a>
                         </div>
                     </div>  

              <div class="col-sm-8">
                  <asp:Panel  ID="Panel1" runat="server" cssClass="pnlEvents" ></asp:Panel>
             </div>
                 </td>                
             </tr>

My code behind error            

Line 52:
Line 53:                 //Add dynamic Panes to static Parent panel
Line 54:                 pnlEvents.Controls.Add(eventPanel);
Line 55:
Line 56:             }
0
Hi Experts,

I am testing my project in multiple computers and found a serious problem.

In Machine 1
I log in as an Admin. Then In the page I have to select Customer, location and Room. Then I click OK to go to a different page. (Sesson Admin='Y')

Then in Machine 2, I log in as a user.  select Customer, location and Room. Then I click OK to go to a different page (Sesson Admin='N')

When I come back machine 1 , where I logged in as Admin='Y' before, it changes it to Admin='N'  and all the selection (Customer, location and Room) has changed to that of machine 2.

What should I do. Please help.

Thanks in advance.
0
Technology Partners: We Want Your Opinion!
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Below codes is to call Twilio API and get the sms historical conversation for one phone no. However, it takes over 15 seconds and the total records is actually just 5 conversation.

Have any experts worked with Twilio in the past and know another way to get SMS conversation in a faster mode?
Thanks,



TwilioClient.Init(accountSid, authToken);
            var messages2 = MessageResource.Read().Where(x => x.From.ToString() == fromPhoneNo);
            var messages3 = MessageResource.Read().Where(y => y.To == fromPhoneNo);
            var all = messages2.Concat(messages3).OrderByDescending(z => z.DateCreated);

Open in new window

0
<asp:GridView ID="grdAdmin" runat="server" AutoGenerateColumns="false" GridLines="None"  CssClass="table table-condensed table-hover table-striped small" data-toggle="bootgrid">
                <Columns>
                    <asp:BoundField HeaderText="#" DataField="ID"  />
                    <asp:BoundField HeaderText="TableID" DataField="TableId" />
                    <asp:BoundField HeaderText="FieldName" DataField="FieldName" />
                    <asp:BoundField HeaderText="isKey" DataField="isKey" />
                    <asp:BoundField HeaderText="canEdit" DataField="canEdit" />
                    <asp:BoundField HeaderText="canFilter" DataField="canFilter" />
                    <asp:BoundField HeaderText="FilterTypeID" DataField="FilterTypeID" />
                    <asp:BoundField HeaderText="SortOrder" DataField="SortOrder" />
                    <asp:BoundField HeaderText="Active" DataField="Active" />
                    <asp:CommandField HeaderText="" />
                </Columns>
            </asp:GridView>


 private void grdAdmin_RowCreated(object sender, GridViewRowEventArgs e)
        {
           
            if (e.Row.RowType == DataControlRowType.Header)
            {
                e.Row.Cells[0].Attributes.Add("data-column-id", "ID");
                e.Row.Cells[0].Attributes.Add("data-identifier", "true");
                e.Row.Cells[0].Attributes.Add("data-type", "numeric");
                …
0
Good Evening,

I have a form that needs to be 508 compliant --  Accessibility.  The form has 1 dropdown and one file input after the dropdown has a value selected and using the tab key how would I set the focus o the input part of the fileupload file type so as not to fail 508.  Tabbing now the focus skips over the input and snags the browse button but if the user then hits enter it triggers validation rather than the window asking for the file to choose.

Someone please help I am very new to 508 and work for the government so this will have to be 508 compliant to get to production.  I have tried focusout onchange and a couple of others but I know I am not doing it accurately.
0
Hi,

I have a form form1 with a datagrid. But i call a second form form2 to made a query, to return only some records. I need to return a datatable to form1 and automatically fill a datagrid.
What is the best way to return a datatable from form2 to form1.

best regards
0
Hello
I have been working on this C# app for some time, off and on in between other projects, and have gotten it this far, but Im having an issue with maximizing it.

I am going to attach 2 images one normal and one maximized to illustrate my issue.
So the first image is the app I designed to sit sort of out of the way while working. But when it is Maximized, I got all the boxes to move, but they wont resize the plugin windows to fit, and I have tried several settings. So I want the VLC Activexplugin to grow when maximized. (all 6) to fit automatically in the area given. Is there a way to accomplish this?

Trying to make it  fit multiple monitors, at different stations, that are different resolutions. I cannot change the sizes to % because it throws errors saying it is invalid property.
Normal.png
Maximized.png
0
To print document I have created separate WindowsApplication and each time I want to print any document I call that application with path as parameter and Print application have below code:

public static void Print(string path)
{
    WebBrowser wb = new WebBrowser();
    wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser_DocumentCompleted);
    wb.Navigate(path);
}

public static void webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
    WebBrowser wb = (WebBrowser)sender;
    if (wb.ReadyState.Equals(WebBrowserReadyState.Complete))
	{
		((SHDocVw.WebBrowser)wb.ActiveXInstance).PrintTemplateTeardown += Print_PrintTemplateTeardown;
        wb.ShowPrintDialog();
	}
}

void Print_PrintTemplateTeardown(object pDisp)
{
	_Application.Exit();
}

Open in new window


When I call Print aaplication, using "WebBrowser" control it loads document and show Print Dialog using "wb.ShowPrintDialog();".
On Print Dialog when I click Print or Cancel I got PrintTemplateTeardown event where I asks Application to Exit (To close application).

Now I want to remove "SHDocVw" dependency from my Print Application due to some security issue while installing on client's machine through Internet.

If I remove "SHDocVw", is there any alternate event or solution available that achknowledge me that PrintDialog is closed?
0

C#

91K

Solutions

32

Articles & Videos

24K

Contributors

C# is an object-oriented programming language created in conjunction with Microsoft’s .NET framework. Compilation is usually done into the Microsoft Intermediate Language (MSIL), which is then JIT-compiled to native code (and cached) during execution in the Common Language Runtime (CLR).