MVC :: Access A Class Function From A View?
Feb 23, 2010I have in my Models folder a Class named "Utilities".
I need to acces one method of that class inside a view, like <%if(IsASelectedCategory(item.categoryId, item.productId))%>
I have in my Models folder a Class named "Utilities".
I need to acces one method of that class inside a view, like <%if(IsASelectedCategory(item.categoryId, item.productId))%>
recommend a data access class / helper class for Access databases, similar to the sqlhelper class found in the (Data Access Application Block)?
View 6 RepliesSince we can access the private data member of base class in the derived class with the help of friend function. How can we do the same in C# asp.net? I mean whats the alternative of friend function in C# asp.net
View 2 RepliesWhen I am creating Strongly Typed View I get lots of Classes in View Data Drop down. Classes like Automapper, ninject, Interface..., latebound... Due this its very hard to find my project classes. Is there any way to restrict dropdown to only display my project classes?
View 1 RepliesI have a class (name PageBase) that is inhariting System .Web.UI .Page and all my .aspx page behind classes are inhariting this class. This way I have put some common things in PageBase class.
For showing errors I want to put showMessage funtion in PageBase as well so that I may have not put it in every page and it will easy to manage this way.
Probem is that how PageBase class will access a control which is in aspx page in its child class (child class of PageBase) .
I dont want to pass control as argument to function in parent class, is ther any other way ?
Suppose we declare and define the variable in one class let say FirstClass and we want to use that variable in another class let say SecondClass which is outside of FirstClass .how to do this?
View 2 RepliesI want to use sum function in access database (not MS SQL) to add array of items in a particular date.For Eg. The Access Database format like
Date
Prod. Name
Value
[code]...
I want to Check Gr #(PK) of student wheter exist in table or not id exist show Msg in Label after lost focus from text box .. I tried AutoNumber in Access but it showing error while insertion
Note : im using form View control for insertion...
i am using the following code for a retrieving a image stored in access database
View 12 RepliesJust wondering how I do this, Im creating a class that will have my common database functions. So for example I've created a function db_con in a class called db_functions.How do i use that db_con function in for example my homepage vb code?Do I import the class? I've tried typing the full class and method name, no joy so far?
View 1 Replieshow to refer shared function in a class , this function itself inside same class
public class cls1
Public Shared Function getDBDate(ByVal pDate As Date) As String
Return Format(pDate, "yyyy-MM-dd")
End Function
Private Function GetDb_Format(ByVal pDateString) As String
Dim d As Date = Me.ParseDate(pDateString)
Return clsDate.getDBDate(d)
End Function
End Class
can i have any other way to use getDbDate function
I'm trying to add a IsImage property that I wrote myself to the HttpPostedFile class, so that if a user is uploading a file, I can do something like this:FileUpload1.PostedFile.IsImageHow can I do that in C#?
View 1 Replieswhat is the function of abstract class, why design pattern need to build BLL and DAL
anyone give an example for my reference as I am getting strat to build my web-based project
I am unsure of how to reference the properties of my class in a function. Here is how I see it in my head, but how do i go about this?
WebService.vb
[Code]....
UserClasses.vb
[Code]....
I have a function in a code behind file that's used to respond to a gridview event:
protected void GridviewEval(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
foreach (TableCell cell in e.Row.Cells)
{
if (cell.Text == "0") { cell.Text = "-"; }
}
}
}
It's currently in the code behind of a page and I'll be using it in other other pages.I would like to use the same code in other pages.When I cut and paste the function into a class,it's not working.
I have an multiview with two views in that and i am trying to access a control in view2 from view1. Like i have a treeview in view1 and and when the treeview gets clicked the iframe in the view2 gets loaded with the document.
View 2 RepliesI'm new to C# and ASP and can't seem to figure out how to write a function to return a CSS Class name.
Here's what I have so far:
In "MyWeb.master" I have a line that reads:
<asp:HyperLink ID="HyperLink1" text="xxxxx"
cssClass='<%# MyCssStyle("ddd") %>'
NavigateUrl="http://www.RDRR.com/Catalog.aspx?TribeID=1"
runat="server" />
And in "MyWeb.master.cs" I have a routine within the partial class that reads:
public string MyCssStyle(string myInput)
{
myInput = "NavigationBarUnselected";
return myInput;
}
This code does not throw an error, but neither does it return a value. What have I missed?
i have my page who load my gridview as: GRW.datasource=className.List2(2);i have this function in my class
[Code]....
it returns an error , cannot convert single result to queryable!! in " blo= DB.MarketList(TypeID);"
We are using ASP security on the site, i found months back a tutorial on implementing a pretty simple management page that allows you to create, edit, delete and add roles as well as adding users to roles from 1 page..
It has been working fine, but we added our own security matrix to the site, everything that has to do with the ASP side of the security works as expected and no issues or concerns.. but with our matrix in place, i need to tie the 2 together for 1 thing.. the deleting of a user..
The delete function works great.. but i would like to add my delete to that function so that the users security matrix is deleted as well when their account is done.
Within the class that is handling all the membership functionality, there is this portion tha handles the deleting, i would like to add a call to my class that has the delete method so that when you click delete, the membership account as well as the matrix record is deleted. Since the delete is already setup within my 2nd class, how can i call it to execute it from within the first class?
[Code]....
How do you reference an asp.net control on your page inside a function or a class.
private void PageLoad(object sender, EventArgs e)
{
//An example control from my page is txtUserName
ChangeText(ref txtUserName, "Hello World");
}
private void ChangeText(ref HtmlGenericControl control, string text)
{
control.InnerText = text;
}
Will this actually change the text of the txtUserName control?
I tried this and is working
private void PageLoad(object sender, EventArgs e)
{
ChangeText(txtUserName, "Hello World");
}
private void ChangeText(TextBox control, string text)
{
control.Text = text;
}
is it possible to make an asynchronous call to a static class function?
View 3 RepliesI have been working a in a function to send all the properties of a class to a store procedure in any DB. I made it work when i define the specific class in the declaration of the function like this:
protected Boolean LoadDataDB(Class1 objClass1,Type t,String StoreProc)
But what i want is to make this function as generic as posible. I thought on replace the "Class1 objClass1" part with something like "object obj" but it didn't work. If Ipull this of, it will be very usefull for me. Up next i'm copying what i have so far.
[Code]....
The error appears in the wrap.AddInParameter line, in the following code:
objeto[Prop.Name.ToString()]
And it says something like "Can not apply indexing with [] to an expression of type object"
I wrote a function in code behind of the aspx file to get from an SQL database the imageurl and assign it to that image's URL. This works fine so I decided to move it to a class but now the imageurl does not exist because the passed image control is now refering to system.drawing.image not the web image.
Code:
Public Sub ShowCodeImages(sProdCode As String, ByRef imgCode As Control, sConnectionString As String)
Dim sSQL As String
Dim sqlDCStock As New SqlConnection
Dim sqlDAStock As SqlDataAdapter
Dim sqlDTStock As DataTable
[Code] .....
I wrote this code in class.cs. But I want call it’s from default.aspx.cs
public ArrayList GetInfos(string NAM)
{
ArrayList list = null;
if (ViewState["ArrayData"] == null)
{
list = new ArrayList();
string str = ConfigurationManager.ConnectionStrings["conString"].ConnectionString;
[Code]......
I am using file upload control in aspx page. I want to put file upload logic in class library. but not getting how to distribute logic.
View 2 Replies