Click here to Skip to main content
15,891,777 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Model PopUp Problem Pin
Andreas X27-May-10 2:12
professionalAndreas X27-May-10 2:12 
QuestionAJAX Tool Kit +ASP.Net Pin
chetan_agarwal25-May-10 21:14
chetan_agarwal25-May-10 21:14 
AnswerRe: AJAX Tool Kit +ASP.Net Pin
AtiqueJnp25-May-10 21:39
AtiqueJnp25-May-10 21:39 
AnswerRe: AJAX Tool Kit +ASP.Net Pin
Sandeep Mewara25-May-10 22:01
mveSandeep Mewara25-May-10 22:01 
GeneralRe: AJAX Tool Kit +ASP.Net Pin
chetan_agarwal25-May-10 23:36
chetan_agarwal25-May-10 23:36 
Questionhow could we know that a method is executing a certain point of time Pin
sainath43725-May-10 18:16
sainath43725-May-10 18:16 
Answer[Repost]: how could we know that a method is executing a certain point of time Pin
Sandeep Mewara25-May-10 18:32
mveSandeep Mewara25-May-10 18:32 
QuestionNeed way to access controls on page from a static method in codebehind. Pin
Adam Brown 325-May-10 10:29
Adam Brown 325-May-10 10:29 
I have an aspx page and and I utilize a static web method defined in the codebhenind of the page. I need a way to access controls on the page to do some databinding from this static method, but when I try to access the control I get the following error:

Error 1 An object reference is required for the non-static field, method, or property 'AccessRequestForm.AssignRole.UpdateRoleGrid

How do I access an instance of the page I am on from a static method? The codebehind I am using is included below:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Xml;
using System.Xml.XPath;
using AccessRequestForm.UtilityServices;
using AccessRequestForm.BusinessServices;
using AccessRequestForm.Models;
using AjaxControlToolkit;

namespace AccessRequestForm
{
    public partial class AssignRole : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                IQueryable<MasterRole> roleList = Role.SelectAll(Convert.ToInt32(strBUSelected));
                lstRoles.Items.Clear();
                foreach (MasterRole role in roleList)
                {
                    ListItem li = new ListItem(role.role_business_desc.ToString(), role.role_id.ToString());
                    lstRoles.Items.Add(li);
                }

                UpdateRoleGrid(roleList);

            }
        }

        public void UpdateRoleGrid(IQueryable<MasterRole> roleList)
        {
            //Databind the Grid
            grdRoles.DataSource = roleList;
            grdRoles.DataBind();
        }

        [System.Web.Services.WebMethod]
        [System.Web.Script.Services.ScriptMethod]
        public static string[] GetCompletionList(string prefixText, int count, string contextKey)
        {
            IQueryable<MasterRole> roleList = Role.SelectStartPattern(Convert.ToInt32(contextKey), prefixText);
            List<string> items = new List<string>(count);
            int i = 0;
            foreach (MasterRole role in roleList)
            {
                if (i++ < count)
                {
                    string strName = role.role_business_desc.ToString();
                    items.Add(strName);
                }
            }
            
            //I get the error here "An object reference is required for the non-static field, method, or property 'AccessRequestForm.AssignRole.UpdateRoleGrid"
            UpdateRoleGrid(roleList);

            return items.ToArray();
        }
    }
}

AnswerRe: Need way to access controls on page from a static method in codebehind. Pin
Not Active25-May-10 17:28
mentorNot Active25-May-10 17:28 
QuestionUpdating contents of GridView from JavaScript Pin
Adam Brown 325-May-10 5:55
Adam Brown 325-May-10 5:55 
AnswerRe: Updating contents of GridView from JavaScript Pin
Viral Upadhyay25-May-10 18:27
Viral Upadhyay25-May-10 18:27 
AnswerRe: Updating contents of GridView from JavaScript Pin
Sandeep Mewara25-May-10 19:11
mveSandeep Mewara25-May-10 19:11 
QuestionExtender controls may not be registered after PreRender Pin
Hendrik Debedts25-May-10 3:00
Hendrik Debedts25-May-10 3:00 
AnswerRe: Extender controls may not be registered after PreRender Pin
Hendrik Debedts25-May-10 3:21
Hendrik Debedts25-May-10 3:21 
Questionhow to print a file without opening it Pin
raghvendrapanda25-May-10 2:44
raghvendrapanda25-May-10 2:44 
AnswerRe: how to print a file without opening it Pin
T M Gray25-May-10 7:45
T M Gray25-May-10 7:45 
AnswerRe: how to print a file without opening it Pin
Pranay Rana26-May-10 0:03
professionalPranay Rana26-May-10 0:03 
GeneralRe: how to print a file without opening it Pin
raghvendrapanda1-Jun-10 9:44
raghvendrapanda1-Jun-10 9:44 
QuestionSystem.IO.IOException Please help me Pin
cheguri25-May-10 0:45
cheguri25-May-10 0:45 
AnswerRe: System.IO.IOException Please help me Pin
P. S. Pundeer25-May-10 1:23
P. S. Pundeer25-May-10 1:23 
AnswerRe: System.IO.IOException Please help me Pin
Sandeep Mewara25-May-10 1:23
mveSandeep Mewara25-May-10 1:23 
Questionurl rewriting and updatepanel issues Pin
aamirzada25-May-10 0:37
aamirzada25-May-10 0:37 
AnswerRe: url rewriting and updatepanel issues Pin
Sandeep Mewara25-May-10 19:13
mveSandeep Mewara25-May-10 19:13 
Questionopening GridView in contentplaceholder of masterpage Pin
mominafiz25-May-10 0:33
mominafiz25-May-10 0:33 
Questionopening GridView in contentplaceholder of masterpage Pin
mominafiz25-May-10 0:56
mominafiz25-May-10 0:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.