mardi 4 août 2015

How can i define "DisplayErrorMessage" in this case?

This is a code that I wrote for my open button ... but I have error on "DisplayErrorMessage" part. What should I write instead? or how can I define it in order not to have the error again.

protected void btnOpen_Click(object sender, EventArgs e)
{
    txtFileName.Text = txtFileName.Text.Trim();
    if (txtFileName.Text == string.Empty)
    {
        string strErrorMessage = "you did Not specify file for opening!";
        DisplayErrorMessage(strErrorMessage);
    }

    string strFileName = txtFileName.Text;
    string strRootRelativePath = "~/app_data/pageContent";
    string strRootRelativePathName =
    string.Format("{0}/{1}", strRootRelativePath, strFileName);
    string strPathName = Server.MapPath(strRootRelativePathName);

    System.IO.StreamReader ostreamReader = null;

    try
    {
        ostreamReader = new System.IO.StreamReader(strPathName, System.Text.Encoding.UTF8);
        litPageMessages.Text = ostreamReader.ReadToEnd();
    }
    catch (Exception ex)
    {
        litPageMessages.Text = ex.Message;
    }
    finally
    {
        if (ostreamReader != null)
        {
            ostreamReader.Dispose();
            ostreamReader= null;
        }
    }
}



via Chebli Mohamed

Get the "indexOf" of an ICollection in Entity Framework

I have two objects that are connected in a way such that ObjectA contains an ICollection of ObjectB. I would like to be able to determine the indexOf ObjectB in inside the ICollection<ObjectB> that is stored in ObjectA.

One of the solutions was to convert the ICollection to a list and then use the built in IndexOf. However, when multiple threads access the ICollection, in many cases, I can get the same indexOf value for multiple ObjectBs.

Question Is there any way to have a certain field (of type int) that stores the index of ObjectB inside the ICollection? If not, is there anyway to ensure that indexOf (when multiple threads attempt to access it) gives the right index (i.e. no matter of the thread)?

Possible solutions I've tried to ensure to use a new context for each look up as well as GetDatabaseValues() and Reload(). This has worked better (especially in Debug mode), but when the debug mode is turned off, the same index of value is given to more ObjectBs.



via Chebli Mohamed

Changing the color of a texbox with a table cell VB ASP.Net

I have created a textbox within a cell of a table and I am using this to take input from a user and display it on a webpage. I however cant get the background of the textbox to change when the user clicks in side the textbox, normally I would use simple CSS for this but as the textbox is inside a table cell I cant seem to be able to work out how to do this. Any Ideas on how to approach this?

I have the following VB code to generate and populate my table.

VB

 Protected Sub GenerateTable(noOfRows As Integer)
    Dim table As Table
    Dim row As TableRow
    Dim cell As TableCell
    Dim tb As TextBox
    Dim lbl As Label
    table = Table1
    table.ID = "Table1"

    For i As Integer = 1 To noOfRows Step 1
        row = New TableRow()
        For j As Integer = 0 To 1 Step 1
            cell = New TableCell()
            If j = 1 Then
                tb = New TextBox()
                tb.ID = "TextBoxRow_" & i & "Col_" & j
                cell.Controls.Add(tb)

            ElseIf j = 0 Then
                lbl = New Label()
                lbl.ID = "Label" & i
                lbl.Text = "Volume " & i
                cell.Controls.Add(lbl)
            End If
            row.Cells.Add(cell)
        Next
        table.Rows.Add(row)
    Next
    ViewState("RowsCount") = noOfRows
    Session("RowsCount") = noOfRows
End Sub

HTML

<tr>
    <td colspan="2">
        <asp:Table class="Table1" ID="Table1" runat="server"></asp:Table>

        <br />
            <asp:Button ID="btnAddVolume" class="btnVolumeBreak" runat="server"  Text="Add Volume Break"/>
    </td>
</tr>



via Chebli Mohamed

Oracle 10G Installation on Windows

I have a database: Oracle SQL Developer 3.2.20.9 an asp.net web application running locally on a pc with Windows 7 enterprise 64 bit, and to developed it I used Visual Studio 2013. Now I should connect the application with the db so I' m trying to install:

Oracle 10g ODAC and Oracle Developer Tools for Visual Studio .NET

I get this Error: "Abnormal program termination. an internal error has occured. Please provide the following files to Oracle Support: Unknown Unknown Unknown"

Could I connect the webapp in other ways? When I go to Server Explorer in Visual Studio and I choose connect to database -> add connection -> Oracle database -> .NET framework Data Provider for Oracle I get: "This provider is deprecated and should not be used. Instead, download Oracle Developer Tools for visual Studio for comprehensive integration with Oracle databases."



via Chebli Mohamed

Why doesn't the value of SPAN update

ASP.net:

<span id="lblScore" class="lblScore">Your Score is: 0</span>
<asp:Label ID="lblHiddenScore" runat="server" CssClass="lblHScore" Text="" ClientIDMode="Static"></asp:Label>

The following jquery is executed after a certain event:

$(".lblScore").text("");
$(".lblScore").text("Your Score is: " + score);
$(".lblHScore").text(score);

I can see in the front-end, the value is changing but when I view the source of the HTML, it doesn't show the changes.

I am trying to use the score value from code-behind:

string yr = lblHiddenScore.Text; //it is always ""

How can I retrieve the value from the front end to use in code-behind



via Chebli Mohamed

Self hosting request logging

With ASP.NET 5 self-hosting, is there any way to configure request logging (as a separate module) much like you can do with IIS logging?

I want to avoid having to add a dependency to Microsoft.Framework.Logging in all my controllers or to hijack a common entry/exit point (such as authentication) for logging (because I want to log the total request processing duration).



via Chebli Mohamed

Example of using ASP.NET Identity 3.0 without Entity Framework

All examples I've seen by now for ASP.NET Identity 3.0 use Entity Framework to store user-related data.

Are there any example which does not use Entity Framework and where ApplicationUser class is not derived from Microsoft.AspNet.Identity.EntityFramework.IdentityUser?

In ASP.NET Identity 2.x it was needed to implement IUser interface. It seems there is not such interface now - so we're not sure how to define User class correctly. There is almost no documentation on this subject.

Second problem is with AddIdentity call in Startup.ConfigureServices. It's pretty tied to the particular classes from Microsoft.AspNet.Identity.EntityFramework namespace and it's unclear how to register identity services without those classes.



via Chebli Mohamed