Click here to Skip to main content
15,895,538 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Inherited controls in datagrid template columns Pin
danasegaranea17-Feb-08 18:54
danasegaranea17-Feb-08 18:54 
GeneralRe: Inherited controls in datagrid template columns Pin
N a v a n e e t h17-Feb-08 19:23
N a v a n e e t h17-Feb-08 19:23 
GeneralRe: Inherited controls in datagrid template columns Pin
danasegaranea17-Feb-08 19:31
danasegaranea17-Feb-08 19:31 
GeneralRe: Inherited controls in datagrid template columns Pin
N a v a n e e t h17-Feb-08 19:47
N a v a n e e t h17-Feb-08 19:47 
GeneralSearch a keyword and highlight it Pin
yadlaprasad17-Feb-08 18:27
yadlaprasad17-Feb-08 18:27 
GeneralRe: Search a keyword and highlight it Pin
Christian Graus17-Feb-08 18:34
protectorChristian Graus17-Feb-08 18:34 
GeneralRe: Search a keyword and highlight it Pin
dilipv17-Feb-08 19:14
dilipv17-Feb-08 19:14 
GeneralTrouble Posting Data from Javascript to ASP.NET in Custom Control Pin
codegal17-Feb-08 18:14
codegal17-Feb-08 18:14 
I'm new to custom controls and having trouble, am working with VS2008: I'm trying to edit an application that uses javascript input control on the page, and PostBackEventHandler and PostBackDataHandler to handle postbacks

We have a main aspx page with a set of controls nested inside one another. I want to create a new nested control consisting of a textbox and an adjacent hyperlink to trigger storage of the contents of the textbox in the class variables of the parent control. I created a simple test app that just includes the custom control directly in the main webpage's codebehind, but can't get the postback working. If I enable script debugging, I get error "Microsoft JScript runtime error: Object expected" at the "__doPostBack('__Page','Hello')" part of the script (from the GetPostBackEventReference") call. Simplified code for my custom control is included below, and below that is the code I include in the .aspx.cs page's codebehind where I'm trying to use the control.

Thank you for any help!

public class MyTestClass : Control, IPostBackEventHandler, IPostBackDataHandler
{
string textBoxValue;
System.Web.UI.Page myPage;

MyTestClass(System.Web.UI.Page myPage)
{
this.myPage = myPage;
}

public event EventHandler LinkClick;
public void RaisePostDataChangedEvent() { }
public void RaisePostBackEvent(string eventArgument)
{
this.LinkClick(this, new EventArgs());
}

public bool LoadPostData(string postDataKey, System.Collections.Specialized.NameValueCollection postCollection)
{
this.textBoxValue = postCollection[this.UniqueID];
return true;
}

protected override void Render(HtmlTextWriter writer)
{
writer.Write("<script language=\"javascript\"> function Test(){ " + myPage.ClientScript.GetPostBackEventReference(myPage, "Hello") + "}</script>");
writer.Write("<INPUT type=\"text\" name=\"" + this.UniqueID + "\" id=\"" + this.ClientID + "\" class=\"size\" value=\"\"/>");

writer.Write("<a name=\"" + this.UniqueID + "\" href=\"#null\" onclick=\"Test();return false;\">myHyperlinkText</a>");
}
}

Codebehind of the web page:
public class MyTestClass : Control, IPostBackEventHandler, IPostBackDataHandler
{
string textBoxValue;
System.Web.UI.Page myPage;

public MyTestClass(System.Web.UI.Page myPage)
{
this.myPage = myPage;
}

public event EventHandler LinkClick;
public void RaisePostDataChangedEvent() { }
public void RaisePostBackEvent(string eventArgument)
{
this.LinkClick(this, new EventArgs());
}

public bool LoadPostData(string postDataKey, System.Collections.Specialized.NameValueCollection postCollection)
{
this.textBoxValue = postCollection[this.UniqueID];
return true;
}

protected override void Render(HtmlTextWriter writer)
{
writer.Write("<script language=\"javascript\"> function Test(){ " + myPage.ClientScript.GetPostBackEventReference(myPage, "Hello") + "}</script>");
writer.Write("<INPUT type=\"text\" name=\"" + this.UniqueID + "\" id=\"" + this.ClientID + "\" class=\"size\" value=\"\"/>");

writer.Write("<a name=\"" + this.UniqueID + "\" href=\"#null\" onclick=\"Test();return false;\">myHyperlinkText</a>");
}
}
QuestionTrigger Pin
senthilsstil17-Feb-08 18:11
senthilsstil17-Feb-08 18:11 
GeneralRe: Trigger Pin
N a v a n e e t h17-Feb-08 18:14
N a v a n e e t h17-Feb-08 18:14 
GeneralRe: Trigger Pin
Guffa17-Feb-08 21:12
Guffa17-Feb-08 21:12 
QuestionWhat is the utility of authorization concepts in web.config , when database is there ? Pin
Sonia Gupta17-Feb-08 18:01
Sonia Gupta17-Feb-08 18:01 
GeneralRe: What is the utility of authorization concepts in web.config , when database is there ? Pin
N a v a n e e t h17-Feb-08 18:15
N a v a n e e t h17-Feb-08 18:15 
QuestionRe: What is the utility of authorization concepts in web.config , when database is there ? Pin
Sonia Gupta17-Feb-08 18:17
Sonia Gupta17-Feb-08 18:17 
GeneralRe: What is the utility of authorization concepts in web.config , when database is there ? Pin
N a v a n e e t h17-Feb-08 18:20
N a v a n e e t h17-Feb-08 18:20 
Questionjavascipt document.getElementByID() problem using MasterPage Pin
sivaprakas17-Feb-08 17:50
sivaprakas17-Feb-08 17:50 
GeneralRe: javascipt document.getElementByID() problem using MasterPage Pin
Venkatesh Mookkan17-Feb-08 18:02
Venkatesh Mookkan17-Feb-08 18:02 
AnswerRe: javascipt document.getElementByID() problem using MasterPage Pin
sivaprakas17-Feb-08 19:37
sivaprakas17-Feb-08 19:37 
GeneralRe: javascipt document.getElementByID() problem using MasterPage Pin
N a v a n e e t h17-Feb-08 20:18
N a v a n e e t h17-Feb-08 20:18 
GeneralVs2005 & vs2003 Pin
Member 387988117-Feb-08 17:37
Member 387988117-Feb-08 17:37 
GeneralRe: Vs2005 & vs2003 Pin
Christian Graus17-Feb-08 18:23
protectorChristian Graus17-Feb-08 18:23 
QuestionObject reference not set and session issue... Pin
Kasic Slobodan17-Feb-08 11:43
Kasic Slobodan17-Feb-08 11:43 
GeneralRe: Object reference not set and session issue... Pin
Christian Graus17-Feb-08 16:42
protectorChristian Graus17-Feb-08 16:42 
GeneralRe: Object reference not set and session issue... Pin
Kasic Slobodan18-Feb-08 9:15
Kasic Slobodan18-Feb-08 9:15 
GeneralASP.NET Image Control at runtime Pin
plural17-Feb-08 10:10
plural17-Feb-08 10:10 

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.