.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

OnPreRender method is Not called last because of objectDataSource

Posted By:      Posted Date: August 31, 2010    Points: 0   Category :ASP.Net
I have an Asp.net web form with several drop down list boxes on it. The way the code is currently set up is that the drop down listboxes are populated through use of an ObjectDataSource via a class named SpottedWeb, as referred to by the TypeName attribute. The problem is that sometimes I need to pre-select drop down list box items, but the ObjectDataSource seems to have the last say in loading the drop down listboxes. So any attempt to pre-select drop down listbox items is undone when my .Aspx code is executed. My attempt to fix this involved creating an OnPreRender method, because I thought it would have the last say with populating my listboxes. But this is not the case.So is there a way that I can have the OnPreRender method or some other C# method be called after the .Aspx page loads my drop downs with the objectDataSource? // Here is my OnPreRender method.         protected override void OnPreRender(EventArgs e)        {            base.OnPreRender(e);             if (Session["Indicator"] != null)            {                PrePopulateWebForm(); // Pre-Sele

View Complete Post

More Related Resource Links

how can i Register multi javascript files with RegisterClientScriptInclude method in OnPreRender


hi friends.

how can i use multi javascript files with RegisterClientScriptInclude method in custom server controls.

when i call two or more  RegisterClientScriptInclude method, this method registers only one of the javascript files.

protected override void OnPreRender(EventArgs e)
            string testJS = Page.ClientScript.GetWebResourceUrl(this.GetType(), "MyControl.js.testJS.js");
            string RichText = Page.ClientScript.GetWebResourceUrl(this.GetType(), "MyControl.js.RichText.js");
            this.Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "MyControl", testJS);
            this.Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "MyControl",RichText); 

i registered javascript files in AssemblyInfo.cs like this :

[assembly: WebResource("MyControl.js.RichText.js", "text/javascript")]
[assembly: WebResource("MyControl.js.testJS.js", "text/javascript")]

Document set - GenerateDocumentID method gets called twice



I have implemented a custom document ID provider and it works fine. But for document set, the GenerateDocumentId method gets called twice.

Am i doing wrong something here or it is like this by design?



Best method for authentication with an external WCF service called from a Silverlight 4 Web Part ins

If we have a Silverlight 4 application which gets its data from an external WCF service and is deployed as a Web Part on in SharePoint 2010 what is the best method to perform authentication in the WCF service itself.  The service is not on the same domain as the SharePoint server but any user authenticated by the SharePoint server (and only those users) should be able to access the service.  Since the Silverlight application is calling the service the WCF service itself must be configured to use BasicHttpBinding which, of course, severely limits possible authentication methods.

Web method called from JavaScript not returning correct type


Hello all-

I have a web method written in VB.Net, coded as follows:

<OperationContract()> _
        Public Function HowManyExportsLeft(ByVal userId As Integer) As Boolean
            _UserId = userId
            Dim MaxExports As Integer = Me.UserSettings.ExportSettings.ExcelExportSettings.MaximumNumberOfExports
            Dim MyExports As Integer = Me.UserSettings.ExportSettings.ExcelExportSettings.MyExportCount
            Dim returnValue As Integer
            If MaxExports = Integer.MaxValue Then
                returnValue = 999
                returnValue = MaxExports - MyExports
            End If
            Return returnValue
        End Function

Now, on the ClientClick method of an asp:Button, I call the following method :

function CheckExportsRemaining() {
    var hdnUserId = $get(CalcResults.Controls.hdnUserId);
    Services.Common.HowManyExportsLeft(hdnUserId.value, ExportCount_complete);

Which of course on success calls this callback method:

function ExportCount_complete(result) {
    if (result <= 3) {
        eACommonDialog.ShowDialog(getURLString(aspxSiteUrl, 'TrialExports.aspx?exportsRemaining=' + result), 420, 215, '', 75, false, true, '', false

ObjectDataSource InsertParameter always passes 0 to Insert method


I have a FormView and ObjectDataSource nested in a GridView.  Each form requires an ID value from the GridView Row it is on.

To accomplish this, I use the GridViewRow_RowDataBound event, and get the ID I need from the GridView's DataKeys.  I then get a handle on my ObjectDataSource for that row using Row.FindControl(), and assign the ID value to the proper InsertParameter[].DefaultValue.

This all seems to work fine, I can verify the value is retrieved and I get no error on the assignment.  Unfortunately, the value passed to my Insert method is always 0, causing a DB error (foreign key violation, because 0 is not valid).

I'm at my wits end as far as figuring out why this InsertParameter won't keep its assigned value.  If anyone can help, I'd appreciate it.

The RowDataBound code:

protected void gvIndicator_RowDataBound(object sender, GridViewRowEventArgs e)
            if (e.Row.RowType == DataControlRowType.DataRow)
                string strGoalIndicatorID = ((GridView)sender).DataKeys[e.Row.RowIndex]["GoalIndicatorID"].ToString();
                //AppUser u = (AppUser)Session["AppUser"];

Missing method called in VB.NET by means of Interop

Hi All,
I've developed a program to automate the execution of some other programs through their visual interfaces.
I've used the functions of User32.dll, Sendmessage, PostMessage, GetMenuItemID, etc, etc.
The program runs successfully on several machines, but not on some others with the same (apparently) OS equipment and configuration which report GetMenuItemID (and any of the above functions) as missing method.
I can't imagine where is the trick.
Any help will be appreciated.

OnPreRender method of GridView control


I was using a reflector and came up on this method OnPreRender() of GridView.

protected internal override void OnPreRender(EventArgs e) 
   if (this.DetermineRenderClientScript() && (this.Page != null)) 
      clientScript.RegisterClientScriptResource(typeof(GridView), "GridView.js"); 

Its calling JavaScript (GridView.js).

Can any one explain the usage of this .js file.

Can we override the file prior rendering of GridView

Thinking about new C# method prototypes: object as dictionary

I recently had to write a small Flickr API. I know many .Net API for Flickr already exist but I needed one for a Silverlight application. Whatever, it's only about building some querystrings so I did it by myself. It's been an opportunity to think again about a classical question: how to pass parameters to a method ?

Imagine you have a generic method to call some Flickr functions.

Sys.Net.WebServiceFailedException: The server method '' failed with the following error:



Let's say we have 2 time consuming functions, aaa and aaa1 inside a aspx page.

        public static string aaa(int i)
            return i.ToString();

        public static string aaa1(int i)
            return i.ToString();



        <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
        <span id="displayspan"></span>
        <br />
        <input type="button" value=

Jscript error: Object does not support property or method


 Hi, i have little knowledge on javascript but i need to use this code get from somewhere for a jquery to work.

I face this "Jscript runtime error: Object does not support property or method" whenever im trying to run this page.

In my experience, im get this error msg 9 out of 10 times i use javascript in my system.

Im using Microsoft Visual web developer 2008, i wonder if this is related to my problem, i not sure there is anything i need to add as reference or update anything.

But anyway, in short, i just couldn't use javascript code when using this development tool because of this sort of error.

Anyway, it happen that last time i tried use the same type of jquery code in another project and it seems to work well without an error.

But now when im try to use it again in this recent project i created, it come out with this error and i have no idea how to solve it even look through google and this forum.

It doesn't really seems like its the code problem itself although im not sure, because any javascript code just couldn't work.

So below is my code that i need to use.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" ></script>
<script type="text/javascript" src=&quo

Using CreateNewUserWizard SendingMail method to email me, not applicatnt.


I have staff area of my site I am protecting with forms authentication using c# and .Net 4.0. What I want to do is let the staff members register on the site but instead of the confermation email being sent to them I want it sent to me so I can go in and approve it. I have been trying to use the SendingMail method  but can not figure out how to get it to email me instead of the person that registered. I have searched around this site and find many topics on the SendingMail method but none seem to properly address my issue. Can anyone help me out?

statement cannot appear outside of a method body


hi all,

  i am posting my vb.net problem .plz tell me how to resolve this :-

Dim conn As String = ConfigurationManager.ConnectionStrings("NorthwindConnectionString").ConnectionString
    'Dim mysqlconnection As New SqlConnection(conn)
    'If mysqlconnection.State=ConnectionState.closed Then mysqlconnection.Open();
    'Dim mySqlcommand As New SqlCommand("select CategoryId,CategoryName from Categories", mysqlconnection)
    'Dim mySqlDataAdapter As New SqlDataAdapter(mySqlcommand)
    'Dim mydataSet As New DataSet()

    'if mysqlconnection.State=ConnectionState.closed Then mysqlconnection.Open();

i m getting 5 errors in this code

declaration expected in mySqlDataAdapter.Fill method; Gridview1.DataSource=ds; Gridview1.DataBind();

Question in Get method in C#


I got a recent working code from client.I see errors in the get methods when i compile , below are some place where the error happens.Can any one help me out?


Error 2 'System.Environment.NewLine.get': cannot explicitly call operator or accessor C:\Documents and Settings\shankar\My Documents\Visual Studio 2008\Projects\DKCLwin\DKCLwin\LocalizationAdmin.cs 150 170 DKCLwin

Error 2 'System.Environment.NewLine.get': cannot explicitly call operator or accessor C:\Documents and Settings\shankar\My Documents\Visual Studio 2008\Projects\DKCLwin\DKCLwin\LocalizationAdmin.cs 150 170

.NET Matters: Restart Manager and Generic Method Compilation


This month Stephen Toub answers questions pertaining to the Windows Vista Restart Manager API and generic method compilation.

Stephen Toub

MSDN Magazine April 2007

Test Run: Determining .NET Assembly and Method References


Before you can test any software system effectively, you must understand the system under test. If the system includes the Microsoft® . NET Framework, understanding the system under test includes understanding its assembly and method dependencies.

James McCaffrey

MSDN Magazine March 2006

Web Q&A: Who Called the Script?, Concatenating Binary Files, and More


This month find out which part of an HTML document has called a script, how to concatenate binary files, find a node, reference one script from another, build a GUI database front end in Access, and compare XML files.

Edited by Nancy Michell

MSDN Magazine August 2003

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend