C# - Difference When Declaring A DataSource In Markup Compared To Code Behind

Jan 13, 2011

I have a legacy solution where all the DataSources are defined in the markup for all .aspx-pages. The problem I have with this is that the DataSource get instantiated several times since it is used in page, control... What I want is to have NInject to handle the instantiation of the DataSource so this doesn't happen. I have got that part to sort of work, but when the DataSource is defined in the code-behind instead of in the markup the Page property is not set on the DataSource, does anyone know why? A simple solution to this is to set the the Page property in a base class or something, but I do think that the property should be there and want to know why.

View 2 Replies


Similar Messages:

Declaring A Constructor Private Or Declaring A Class Sealed Is Same Thing?

Oct 12, 2010

Is declaring a constructor private or declaring a class sealed is same thing?

View 1 Replies

DataSource Controls :: Amount Of Time Between Two Dates Compared To A Value Using Linq?

Apr 8, 2010

How would I determine the amount of time in weeks between two dates and compare that value to another value in Linq, for example:

Where the amount of time in weeks between (startdate and enddate) = value x

View 1 Replies

DataSource Controls :: Declaring New Sql Connection Failed?

Jan 13, 2010

I got a simple SQL Connection which works fine under VS 2005, once I convert to VS 2008, is failed to work. I even re-build entire apps from scratch under VS 2008, yet it still failed.

Here's the code.

[Code]....

The code failed at this line:

objCon = New SqlConnection()

Error message being:

The type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception.

View 4 Replies

DataSource Controls :: Declaring Today's Date In A Stored Procedure?

Apr 6, 2010

Can someone tell me the syntax to declare today's date in a stored procedure? I've searched around and can't come up with a clear answer.

I'm trying to declare today's date in the stored procedure and then compare it to a date in a database?

Is it as simple as the following or am i way off?

[Code]....

View 5 Replies

C# - Possible To Do Inline Code In ASPX Markup

Jun 1, 2010

Is it possible to do things in a PHPish way in ASP.Net? I've seen <%= %> but I've tried it and couldn't get it to work. The PHPish equivalent of what I want to do is

<script src="<?php echo ResolveUrl("jquery/js/jquery.js"); ?>"></script>

View 1 Replies

Write HTML Markup From Code Behind?

Apr 4, 2011

What is the Best way to write my own HTML from code behind?

i currently use this :

<asp:Literal ID="ltr" runat="server"></asp:Literal>

and from code behind :

ltr.Text = "<p class="specific-class"></p>";

is it a right to do something like this?

View 2 Replies

C# - Code In Markup For A Link-href (.Net)?

Dec 17, 2010

I have an aspx-Page with an anchor-tag. Itīs href has to take a parameter of thepage, which is a public member.public int CommissionId

{
get
{
//..
}
}

I know how to design the link in code-behind, but want to do it in Markup.I tried

<a href='<% String.Format(@"Details.aspx?commissionId=" + CommissionId) %>' runat="server" id="cancelLink" class="button" onclick="this.blur();"><span>Back</span></a>

View 2 Replies

Development Server Is Not Updating Changes To Markup / Code?

Sep 1, 2010

I've been working on the ASP.NET Development Server recently (on an MVC project and I'm finding that it is inconsistent in how it serves the changes I make to my code. For example, I make a change to the C#/HTML/CSS/JS in the dev environment and run the page, and the change appears on the screen. But if I edit the HTML again and run the page again, the new change doesn't appear. Even ctrl+F5 doesn't do it. I have to stop the web server and run the app again for the changes to update. Has anyone else experienced this? Is there a way to sort this problem out?

If I'm working in IIS and I change something, a ctrl+F5 will always update the page with the changes I've made. I'd like the dev server to be as reliable.

View 2 Replies

WebMatrix :: Razor Syntax - Separate Code From Markup

Aug 28, 2010

While it has gnerally been advocated to separate code from mark up and all that, with the razor syntax and webmatrix all that is not valid anymore, I think. WebMatrix encourages code and mark up in the same page! So what is the best practice as far as code and mark up is concerned.

View 6 Replies

E-mailing Forms: Adding HTML Markup To Code-behind?

Apr 13, 2010

I'm trying to add some basic HTML markup to my code-behind, just a H1 and a few breaks separating strings in the message.Body, but can't seem to get it going without errors.

[Code]....

Probably a straightforward thing, or not intended usage at all,

View 4 Replies

.net - Markup Code Inside Custom Server Control?

Dec 29, 2010

I'm new to custom server controls and I'm hoping to use them to build various 'modules' for different sites I build to cut down on duplicate code.I'm familiar with custom user controls in which I can create an .ascx & .ascx.vb file which can then be imported into an .aspx page and used freely.However, with custom server controls I cannot find a way of using markup/html code. Is this possible at all or must all code be created programmatically?

View 1 Replies

Accessing User Control Properties Defined In Code Behind In Markup?

Feb 9, 2011

I have a public property defined in code behind of a user control. I want to toggle visibility of controls in the markup based on the property's value.

However, using the following syntax:

<td style="display:<%#(Container.PageControlMode == PageControlMode. PageMode.Wizard) ? "none" : "inline" %;">

I have the following property in my code behind:

public PageMode PageControlMode { get; set; }

Does not work and generate errors.

View 1 Replies

Way To Use VS 2005 Gridview Delete Button With Datasource Markup

Jul 24, 2010

using gridview delete button with datasource markup:
source Code:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:direct_deliveryConnectionString %>"
SelectCommand="select pk_ddlvryDetailID,fk_grfdetailID,itemDescription,qty,uom,rate,(qty*rate) as Amount
from qddlvrydetails
where fk_ddlvryMasterID=@id"
DeleteCommand="delete
from tblddlvrydetails
where pk_ddlvrydetailid=@id">
[code]...
I created a parameter named @ID which will received value from grid selectedvalue whenever the delete button fire up but whenever i do that the will just postback without delete the row.

View 5 Replies

DataSource Controls :: Setting Where Parameters Within Linq Markup

Oct 19, 2010

I've got a Linq datasource hitched up to a Formview control for clients to edit some data. I'm having trouble setting the where parameters withing the control so it show the right set of data. Here's the markup:

[Code]....

Upon running right now, it's completely ignoring the where parameters. What am I missing here?

View 3 Replies

C# - Extend Control (ASCX) And Access Base Markup File From Subclass Code?

Jan 29, 2010

I'm building form validation controls for our C# ASP application. The bulk of the work is handled by a BaseValidator control (subclassing System.Web.UI.UserControl), which also has the markup for the validation output. This is then extended by subcontrols like PasswordValidator, that provides the Validate method and any extra fields needed by that validator control.

(The end goal is to have controls like <uc1:PasswordValidator ControlId="txtPassword" /> which we can plop into any form with minimum duplication.)

However, PasswordValidator.ascx.cs cannot access the form elements defined in BaseValidator.ascx; the only way I've found to do so is to duplicate the markup in each subcontrol's *.ascx file. How can I extend BaseValidator.ascx.cs and access BaseValidator.ascx's markup in the subclass?

View 3 Replies

Difference Between UnManaged Code And UnSafe Code?

Sep 9, 2010

What is the difference between UnManaged code & UnSafe code???? Explain with an example

View 2 Replies

Difference Between Object Code And Embedded Code?

Aug 26, 2010

i have a doubt difference between object code and embeded code .

View 2 Replies

Web Forms :: Timer Control In Markup, But Code-behind Saying "not Declared"

Dec 28, 2010

When I first created a timer (Timer1) I handled the Tick event. No problem, intellisense worked and the timer control was declared then. I toggled it's enabled property, no problem.

I just went to look back at the _Tick event for the Timer1 control, and it has the blue underline mark in VWD that says that Timer1 is undeclared. I looked back at the markup and the <asp:Timer ID="Timer1" runat="server" ... /> control is there. I don't understand why all of a sudden my code-behind class is not recognizing the ID of my timer control.

The page runs fine, but it is throwing me off why VWD is seeing this as an error when I hard-type the control name.

View 9 Replies

How The Server Process The Page - Code Behind - "markup Mixed With HTML Elements"

Oct 23, 2010

I want to know how the server will process my page that contain:

1- ASP.NET markup mixed with HTML elements.
2- Code behinde.

Will it read the ASP.NET markup line by line and even HTML elements? And then reads the code behind? or what exactly?

View 1 Replies

How To Make Difference In Code

May 11, 2010

This works and returns false ===> (username: <%= this._securityAccesspageBase.DirectReportAccesses.Count > 0 ? false :true%> )

This works doesnt work I was expecting false for the visible property:

[code]....

View 4 Replies

JQuery :: Learning Curve / Compared To AJAX?

May 21, 2010

I've been thinking about starting to work with AJAX because it seems easy to use things like the update panel. I also want to use a modal popup. I know that JQuery has some really stuff and I want to use it eventually. I want to take the path of least resistance for now though.

there seems to be some overlap in what the two technologies offer. There are similar things offered in both of them. I think I have to use AJAX for the partial page updates though.

How is the learning curve for JQuery compared to AJAX?

View 5 Replies

VS 2012 - How To Tell Difference Between Source And Published Code

Feb 5, 2014

How can I tell the difference between source and published .NET code?

I am looking at some inherited code that I have not touched in about a year. The original designer had me first publish locally before uploading the published code to the internet server. Now I am looking a number of backed up source folders as well bas backed up published folders. I should have done a better job at naming the folders, I guess. Now I wonder: How can I tell the difference between source and published .NET code? Is there some easy way to see if some folder that contains only published code is lacking a file or xml setting?

Is the .csproj file or the .sln file part of the code pushed to the server when you publish? What other differences are there that I are immediate and obvious?

View 1 Replies

C# - WebMethod() Is Slow On Each Execution Compared To After Run It As A Windows Application

Mar 11, 2011

I have developed an application that interacts with IBM ClearQuest. The problem is that when I run everything locally, such as, run the webservice local and then ASP page local everything is at the speed I expect. When I post the webservice (precompiled) to the server and run the web page through the server, the call to the webmethod takes at least 10x the amount of time it should. I dont know why this is happening. I made a console application that has the function in question and execute it on the server and locally and they both return the same amounts of time (roughly) its just when I move to executing via the webmethod everything grinds to a snails pace. Any ideas? This happens every time not just on the first call.

WebMethod:

Public Function RetrieveQueryResults(ByRef cqSession As ClearQuestOleServer.Session, _
ByVal sqlStmt As String) As List(Of SearchResultsSingleIssue)
Dim numCols As Integer, status As Integer, columnIdx As Integer
Dim numRows As Integer
Dim rowContents As String = ""
Dim colValue As New Object
Dim colLabel As New Object
Dim allitems As New List(Of SearchResultsSingleIssue)
Dim results As New SearchResultsSingleIssue
Dim cqResultSet As ClearQuestOleServer.OAdResultset
cqResultSet = cqSession.BuildSQLQuery(sqlStmt)
cqResultSet.Execute()
' Get the number of columns returned by the query.
numRows = 0
numCols = cqResultSet.GetNumberOfColumns
status = cqResultSet.MoveNext
' Collect query results.
Do While status = AD_SUCCESS
results = New SearchResultsSingleIssue
numRows = numRows + 1
For columnIdx = 1 To numCols
colLabel = cqResultSet.GetColumnLabel(columnIdx)
colValue = cqResultSet.GetColumnValue(columnIdx)
'Make sure that we dont pass along a null reference
If colValue = Nothing Then
colValue = ""
End If
Select Case colLabel
Case "ID"
results.IssueID = colValue
Case "HEADLINE"
results.Headline = colValue
Case "NAME"
results.State = colValue
Case "OE_CONTACT"
results.OEContact = colValue
Case "DESCRIPTION"
results.Further_Description = colValue
Case "PRODUCT_NAME"
results.Product_Name = colValue
Case "FUNCTIONAL_AREA"
results.Functional_Area = colValue
Case "SUBTOPIC"
results.Subtopic = colValue
Case "FOUND_VERSION"
results.Found_In = colValue
Case "SCHEDULED_VERSION"
results.Scheduled_For = colValue
Case "SYMPTOMS"
results.Symptoms = colValue
Case "AFFECTED_SYSTEMS"
results.Affected_System_Types = colValue
Case "ISSUE_TYPE"
results.Issue_Type = colValue
Case "ASSIGNED_TO"
results.Assigned_Developer = colValue
Case "TESTED_BY"
results.Assigned_Tester = colValue
Case "BUILT_VERSION"
results.Built_In = colValue
Case "TESTED_VERSION"
results.Tested_In = colValue
Case "NOTES_LOG"
results.Notes_Log = colValue
Case "CUSTOMER_SEVERITY"
results.Severity = colValue
Case "PRIORITY"
results.Priority = colValue
End Select
Next columnIdx
' Add the query row result to the compiled list of all rows.
allitems.Add(results)
status = cqResultSet.MoveNext
Loop
Return allitems
End Function

Local Windows Application Method:

private void button2_Click(object sender, EventArgs e)
{
start = DateTime.Now.TimeOfDay.Seconds;

int numCols = 0;
int status = 0;
int columnIdx = 0;
int numRows = 0;
string rowContents = "";
string colValue;
string colLabel;
List<SearchResultsSingleIssue> allitems = new List<SearchResultsSingleIssue>();
SearchResultsSingleIssue results = new SearchResultsSingleIssue();
ClearQuestOleServer.OAdResultset cqResultSet = default(ClearQuestOleServer.OAdResultset);
cqResultSet = (ClearQuestOleServer.OAdResultset)ClearQuestSession.BuildSQLQuery(sqlStatement);
cqResultSet.Execute();
// Get the number of columns returned by the query.
numRows = 0;
numCols = cqResultSet.GetNumberOfColumns();
status = cqResultSet.MoveNext();
// Collect query results.
while (status == 1)
{
results = new SearchResultsSingleIssue();
numRows = numRows + 1;
for (columnIdx = 1; columnIdx <= numCols; columnIdx++)
{
colLabel = (string)cqResultSet.GetColumnLabel(columnIdx);
colValue = (string)cqResultSet.GetColumnValue(columnIdx);
//Make sure that we dont pass along a null reference
if (colValue == null)
{
colValue = "";
}
switch (colLabel)
{
case "ID":
results.IssueID = colValue;
break;
case "HEADLINE":
results.Headline = colValue;
break;
case "NAME":
results.State = colValue;
break;
case "OE_CONTACT":
results.OEContact = colValue;
break;
case "DESCRIPTION":
results.Further_Description = colValue;
break;
case "PRODUCT_NAME":
results.Product_Name = colValue;
break;
case "FUNCTIONAL_AREA":
results.Functional_Area = colValue;
break;
case "SUBTOPIC":
results.Subtopic = colValue;
break;
case "FOUND_VERSION":
results.Found_In = colValue;
break;
case "SCHEDULED_VERSION":
results.Scheduled_For = colValue;
break;
case "SYMPTOMS":
results.Symptoms = colValue;
break;
case "AFFECTED_SYSTEMS":
results.Affected_System_Types = colValue;
break;
case "ISSUE_TYPE":
results.Issue_Type = colValue;
break;
case "ASSIGNED_TO":
results.Assigned_Developer = colValue;
break;
case "TESTED_BY":
results.Assigned_Tester = colValue;
break;
case "BUILT_VERSION":
results.Built_In = colValue;
break;
case "TESTED_VERSION":
results.Tested_In = colValue;
break;
case "NOTES_LOG":
results.Notes_Log = colValue;
break;
case "CUSTOMER_SEVERITY":
results.Severity = colValue;
break;
case "PRIORITY":
results.Priority = colValue;
break;
}
}
// Add the query row result to the compiled list of all rows.
allitems.Add(results);
status = cqResultSet.MoveNext();
}
seconds = (DateTime.Now.TimeOfDay.Seconds - start);
label3.Text = seconds.ToString();
}

The code should execute in about...6 seconds.

View 1 Replies

Performance Difference In Having Huge Javascript Code Against .js File

Dec 9, 2010

We have a .aspx file which has about 400 lines of javascript code. Is it a good idea to have such huge code in its own file? What is the performance difference in having huge javascript code in aspx as against the .js file?

View 5 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved