Write An Extension Method Or Alternative To Make HtmlTable As Enumerable Row Collection?
Aug 7, 2010
I want to iterate through HtmlTable (Server Side) in ASP.NET 3.5.
foreach (System.Web.UI.HtmlControls.HtmlTableRow trow in someTable)
{
var x = trow.InnerText;
}
I received an error message that "System.Web.UI.HtmlControls.HtmlTable" does not contain a definition for GetEnumerator.
How to write an extension method or alternative to make HtmlTable as enumerable row collection?
View 2 Replies
Similar Messages:
Jan 28, 2011
I'm trying to follow the demo from this link to add a jqGrid to an MVC app.
I have a table named Companies that I'm trying to display in a grid. A Company simply contains an ID and a Name.
I'm running into an error in my controller function:
public JsonResult DynamicGridData(string sortIndex, string sortOrder, int page, int rows)
{
int pageIndex = Convert.ToInt32(page) - 1;
int pageSize = rows;
var companies = companiesRepository.Companies.OrderBy(sortIndex + " " + sortOrder).Skip(pageIndex * pageSize).Take(pageSize);
//Error here
...
}
I'm getting an error on the line that is calling OrderBy():
The type arguments for method 'System.Linq.Enumerable.OrderBy(System.Collections.Generic.IEnumerable, System.Func)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
I really have no idea what the error means, and I haven't been able to find an explanation. I'm not sure what is causing this error on a simple OrderBy function.
View 2 Replies
Mar 29, 2011
I am reading in a file into a string. Then I am writing this string to a stream. I know this code works fine.
The only problem that I have is with the line that write the data in chunks where the parameters is not supported for the Write method.
The line that has the problem is this line. What do I need to change here?
OutPut.Write(buffer, 0, Math.Min(to_write, WRITE_CHUNK));
[Code]....
View 2 Replies
Apr 21, 2010
I loved the features of using app_offline.htm on my ASP.NET WebForm based sites.
Upload the file and your app is immediately "offline". Snappy.
Now that I'm using MVC 2, I noticed that this no longer works.
Is there a way to get this behavior in ASP.NET MVC 2 like it did in WebForms?
View 1 Replies
Sep 16, 2010
I am trying to freeze my gridview header for last 2 days and got this link and many other links too provided to me on Stackoverflow as well as from googling. This worked fine when i used it on IE 6,7 and under compatibility mode in IE8 but in normal mode, this code is not working.
This line is giving me an error. I want to implement this functionality.
trs[x].style.setExpression("top", "this.parentElement.parentElement.parentElement.scrollTop + 'px'");
On reading comments, I came to know that scrollableTable.js uses setExpression Method which has been depreciated in IE8.
How to replace setExpression method with some other alternative in this code
[code]....
View 3 Replies
Mar 17, 2010
In uploading files and determining their length, I want to know if there is any alternative to
<code>
file1.PostedFile.ContentLength
</code>
It seems that this quantity is counted up as the actual uploading is taking place.
Once the customer has selected his file-to-be-uploaded and put it in the textbox, is there any
other way for my script immediately to say "This file is 5 Mb and it is therefore too big" ?
View 1 Replies
Feb 23, 2010
Most of my experience has been developing 'webpages'. Presently, I am developing a mozilla extension which does not support web services, others have suggested to use XMLHttpReqest instead. I have the client side code for it but have no idea on how to write the server side for it.
View 2 Replies
Feb 12, 2010
i saw the extension method code but i could not understand what it is and what is the utilities of extension method.
View 3 Replies
Aug 19, 2010
I have a table with 4 columns: ID, signId, storeNum, quantity with ID, SignId, and storeNum as composite primary keyif storeNum is -1, that means the quantity is the default quantity. If a store has a store-specific quantity, the storeNum is this store's number.
I need to show all rows that have specific quantity for a store, and all rows that have default quantity and of which the store does not have store-specific quantity
currently I use table-value function with storeNum as parameter to return the list. first, I get all rows that have specific quantity for a store; then, I use cursor to loop through all rows that have default quantity and check each row if the store has a specific quantity. It takes 9 seconds to run the function for a store.
The function is called within a stored procedure, which in turn is called by a function in a class, which in turn is called by a aspx code behind file. It takes about 20 seconds to load the page. 20 seconds to load a page is too long. I am trying to improve
the performance.
I wonder if there is an alternative method to the cursor to get the second part of the list.
View 3 Replies
Feb 1, 2011
i have just found that i cant create postback triggers on the fly (i had a function that runs onclick that creates buttons and postback triggers)
so i need an alternative or a method to achieve this
what happens is onclick of a button, updatepanel1 is updateded and depending on what button you click in panel1 more buttons are added, these buttons that are added also have an oncllick event that should update a wysiwyg in panel2 with content
heres my code below, if anyone has any ideas or knows of other methods to get this to work it would be great
[Code]....
View 23 Replies
Oct 14, 2010
how can i make urls without extention it means without .aspx or .html??
View 3 Replies
Mar 12, 2011
I am using Tuple class in WCF Service. When i add reference to my web project I get Tuple class. Now i want to add an extension method to Tuple<> class in my service which will be accessible in my Web project.
View 1 Replies
Feb 22, 2010
I want to ask, does adding extension methods to datatypes works in the same way as Microsoft's methods or do they have any limitaion.
This is relevant to experienced programmers who had find some limitations while using them.
View 3 Replies
Mar 9, 2010
I recently found out about C# extension methods and wrote this one:
/// <summary>
/// Short-hand for setting the data source and binding it.
/// </summary>
/// <param name="me">The control to set and bind the data source of.</param>
/// <param name="dataSource">The data source.</param>
public static void BindTo(this DataBoundControl me, IEnumerable dataSource)
{
me.DataSource = dataSource;
me.DataBind();
}
What do you guys think? Is this a reasonable extension method to use in a professional ASP.NET project?
View 4 Replies
Sep 5, 2010
I have the following Extension Method
Imports System.Runtime.CompilerServices
Namespace Extensions
Public Module IntegerExtensions
<Extension()>
Public Function ToCommaDeliminatedNumber(ByVal int As Integer) As String
Dim _input As String = int.ToString
Select Case int
Case Is > 99999 : Return _input.Remove(_input.Length - 3) & "k"
Case Is > 9999 : Return Math.Round(Double.Parse(int / 1000), 1).ToString & "k"
Case Is > 999 : Return String.Format("{0:N0}", int)
Case Else : Return _input
End Select
End Function
End Module
End Namespace
And in one of my classes I'm using user.Reputation.ToCommaDeliminatedNumber I am importing the Extensions Namespace into the Class, but the error I'm getting is...'ToCommaDeliminatedNumber' is not a member of 'Integer?'. I do have other Extension Methods for Strings and Dates that work exactly as expected... I'm just at a loss on this one.
View 1 Replies
Oct 8, 2010
I know there is a ListBoxFor extension method among the ASP.NET MVC Html helper extension methods, but I always thought that a checkbox list is more user-friendly than a list box.
There was a very convenient CheckBoxList control in good old WebForms, but obviously that is out of the picture now. The question is, why is there no way in ASP.NET MVC to create a check box list? How can I write my own extension method that creates a check box list and behaves in a similar way ListBoxFor behaves?
View 3 Replies
Dec 21, 2010
I am stuck with the database row level security model that my predecessor has implemented on this project. I am trying to make an extension method for my linq to sql classes to make it easier to filter rows of data in my linq queries. The problem I am facing is that I need to somehow tell it how to access the primary key value of the object in the where clause. I get errors about DynamicInvoke(object[]) cant be converted to SQL. Here is a sample of what I am working with:
[Code]....
How do I do this?
View 1 Replies
Jul 9, 2010
VWD 2008 Express. Visual Basic.
I am using the Directory.GetFiles method as follows:
[Code]....
As expected, it returns files with the ".pdf" extension. I would like to be able to specify more than one extension (like "*.doc*" and "*.txt*", etc.). How can I use GetFiles to return files with more than one desired extension, without returning all files?
View 2 Replies
Jan 18, 2011
I'm binding an object to a gridview. The object (LeClient) consists of several variables, two of which are related to its phone number. One variable contains a string of digits (LePhone) and the other contains an int that represents the country code (LeCountryCode). I have an extension method for strings that works to format the string LePhone and that I'd like to pass it LeCountryCode as the parameter.
So far, on RowDataBound I have an event handler with the following line:
e.Row.Cells[5].Text = (string)(e.Row.Cells[5].Text).ToPhoneFormat(1);
I'd like to replace the 1 with the corresponding country code that's stored in the object LeClient associated with the row. How does this work? I tried
.ToPhoneFormat(e.Row.DataItem("LeCountryCode"));
View 1 Replies
Jul 20, 2010
Is it possible to select multiple entiies in ForEach Extension Method?
(i.e)
partial code is given
DataTableA.AsEnumerable().ToList().
ForEach(x=>
{
x.SetField<string>("Name","Jon Skeet"),
x.SetField<string>("msg","welcome")
});
when i apply multiple selection in ForEach
x=>
{
x.SetField<string>("Name","Jon Skeet"),
x.SetField<string>("msg","welcome")
}
I am unable to complete the statement.
View 1 Replies
Jan 18, 2011
I would like to know what the pros and cons are of creating an extension method v a partial view. From my understanding, htmlHelper extension methods are better as they enable one to unit test the view.
e.g. Assert.AreEqual(Html.Price(), "<td><tr><td>Price</td><td>4.50</td></tr>");
where the Price() method contains the presentation logic.
Since both the extension method and partial view are reusable, what then is the point / benefit of a partial view?
View 7 Replies
Oct 28, 2010
I have a hierarchy in my website project as below:
[CustomControl1 - folder]
- CustomControl1.ascx
- CustomControl1.css
- CustomControl1.js
I load css and js files dynamicaly based on which controls are used on particular page. I am doing it by using following code:
[code]....
where AddLinks method adds HtmlLink controls to Page.Header with href attribute set to coresponding css and/or js file.
I would like to add Interface that would force new controls to have AddLinks method but it is impossible since it is a static method. Because my custom controls inherit from Control class I cannot use abstract class and/or virtual methods either. How can I achieve my goal?
View 1 Replies
Nov 10, 2010
I'm trying to let the user download different documents where the data is stored in an SQL DB. In firefox, the filetype is correctly read, but not in IE. I'm trying to do this without having to set the ".pdf" or whatever extension the document has, because I haven't got that information. I only have the filetype.
[Code]....
View 3 Replies
Mar 23, 2010
I have an extension method which I can use from the .cs codebehind of an aspx page, but if I try to do it in a code block in the aspx, it can't find the extension method. Is there something I need to add to the page?
View 2 Replies
Oct 24, 2010
Inside my repeater I'm calling an extension method like so:
[Code]....
he above is giving me an "Object not set to an instance of a object" exception inside the extension method. If I comment the above expression out, it works fine, and the items are binded wtih no problems.
View 1 Replies