Vinoth Kannan
Vinoth Kannan

Reputation: 69

IsPostback always false when i click button or any other

Am using asp.net for above 5 years. But now am facing a weird problem. When i try to send emails from form created by me which contains asp:button, asp:textbox, etc., in code page it always telling IsPostBack false. Even when i click the Send mail button(asp.net button). I cant understand what is problem.

Is it anything needed in web.config file for postback??

Test page http://buyerrs.com/Test.aspx

Am sure its not problem in Test page. Because it is very normal page which have only one button & code in vb. Problem somewhere in cache, urlrewrite or web.config. But i cant understand where?

    <?xml version="1.0" encoding="UTF-8"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">

  <configSections>
    <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
      <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
        <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
        <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
          <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" />
          <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
          <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
          <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
        </sectionGroup>
      </sectionGroup>
    </sectionGroup>
  </configSections>

   <system.web>

     <httpHandlers>
       <remove verb="*" path="*.asmx"/>
       <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
       <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
       <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
     </httpHandlers>

      <httpModules>
        <add name="vchHttpModule" type="VchBaseSite.vchHttpModule" />
      </httpModules>

      <!-- need to increase the size of the permitted upload size -->
      <httpRuntime maxRequestLength="20480" />

      <!-- set compilation debug="false" for running application -->
      <compilation debug="true" strict="false" explicit="true" defaultLanguage="vb">
         <assemblies>
            <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
            <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
           <add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
         </assemblies>
      </compilation>

      <trace enabled="false" pageOutput="true" localOnly="true" />

      <sessionState mode="Off" />

      <!-- customErrors mode="On|Off|RemoteOnly" -->
      <customErrors mode="Off">
         <error statusCode="404" redirect="404.aspx" />
         <error statusCode="500" redirect="500.html" />
      </customErrors>

      <pages enableViewState="false">
         <namespaces>
            <clear />
            <add namespace="System" />
            <add namespace="System.Collections" />
            <add namespace="System.Collections.Generic" />
            <add namespace="System.Configuration" />
            <add namespace="System.IO" />
            <add namespace="System.IO.Compression" />
            <add namespace="System.Linq" />
            <add namespace="System.Text" />
            <add namespace="System.Web" />
            <add namespace="System.Web.Security" />
            <add namespace="System.Web.UI.WebControls" />
            <add namespace="System.Web.UI" />
            <add namespace="System.Xml.Linq" />
         </namespaces>
         <controls>
           <add tagPrefix="vch" namespace="VchBaseSite" assembly="VchBaseSite" />
         </controls>
      </pages>

      <!-- set code access security trust level - this is generally set in the machine.config
      <trust level="Medium" originUrl=".*" />-->

      <machineKey
        validationKey="CF19275EF5E6206C1E289BAC5240240548B1015A2A68137B411A08E2F2BFE55223C42B1FECB10B6A660CD00DEE02F005959D7E4929660A81CF756E69BF3F56C8"
        decryptionKey="A32BD7AEDF208B05B85828E644774810C928F5F76A6AD0A50F982EBD235634A3"
        validation="SHA1" decryption="AES"
      />

      <authentication mode="None" />

      <roleManager>
          <providers>
              <clear />
          </providers>
      </roleManager>

   </system.web>

   <system.codedom>
      <compilers>
         <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
            <providerOption name="CompilerVersion" value="v3.5" />
            <providerOption name="WarnAsError" value="false" />
         </compiler>
         <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
            <providerOption name="CompilerVersion" value="v3.5" />
            <providerOption name="OptionInfer" value="true" />
            <providerOption name="WarnAsError" value="false" />
         </compiler>
      </compilers>
   </system.codedom>

   <!--
     The system.webServer section is required for running ASP.NET AJAX under Internet
     Information Services 7.0.  It is not necessary for previous version of IIS.
    -->
   <system.webServer>
      <validation validateIntegratedModeConfiguration="false" />


<!--
      <defaultDocument>
         <files>
            <clear />
            <add value="default.aspx" />

          <add value="Default.aspx" /> 
            <add value="default.htm" />
            <add value="Default.htm" />
         </files>
      </defaultDocument> -->
   </system.webServer>

   <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" appliesTo="v2.0.50727">
         <dependentAssembly>
            <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
         </dependentAssembly>
         <dependentAssembly>
            <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
         </dependentAssembly>
      </assemblyBinding>

      <connectionStrings>
        <remove name="LocalSqlServer" />
      </connectionStrings>
   </runtime>

</configuration>

this is web.config file

Finally I found where the error rising. This website code based on this http://www.datafeedscripts.net/default.aspx software. They are using three dll files (vchsite.dll, vchLicense.dll, vchbasesite.dll) and have a httpmodule code below

<httpModules>
    <add name="vchHttpModule" type="VchBaseSite.vchHttpModule" />

When i exclude that dlls and remove the httpmodule line from web.config file postback working fine. So this is error. They done something wrong in their Dll files or httpmodule.

But still can't understand what is error. Is it have chance to control postback action from dll files?

Upvotes: 1

Views: 14571

Answers (6)

Steve
Steve

Reputation: 2046

I know this is a bit old but I would check the HttpModule. The vchHttpModule could be hijacking the request and invaliding the IsPostBack.

Upvotes: 2

Adrian Iftode
Adrian Iftode

Reputation: 15663

I took a look at the IsPostBack MS implementation, which it can be found here also

Via reflection you can "read" each value used in those if statements.
Unfortunately I use C#, I hope you can translate it to VB

protected void Page_Load(object sender, EventArgs e)
        {
            Response.Write(IsPostBack.ToString() + " " + DateTime.Now.ToShortDateString());
            Response.Write("<br />");
            
            //return this._requestValueCollection != null && (this._isCrossPagePostBack 
            //|| (!this._pageFlags[8] && (this.Context.ServerExecuteDepth <= 0 
            //        || (this.Context.Handler != null && !(base.GetType() != this.Context.Handler.GetType()))) && !this._fPageLayoutChanged));

            var pType = this.GetType();
            while (pType.Name != "Page")
                pType = pType.BaseType;
            var _requestValueCollection = pType.GetField("_requestValueCollection", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(this);
            Response.Write("_requestValueCollection: " + (_requestValueCollection != null).ToString());
            Response.Write("<br />");

            var _isCrossPagePostBack = pType.GetField("_isCrossPagePostBack", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(this);
            Response.Write("_isCrossPagePostBack: " + _isCrossPagePostBack);
            Response.Write("<br />");

            var _pageFlags = pType.GetField("_pageFlags", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(this);
            Response.Write("_pageFlags: " + (((int)_pageFlags.GetType().GetField("data", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(_pageFlags) & 8) == 8));
            Response.Write("<br />");
            //SimpleBitVetctor32
            var cType = this.Context.GetType();
            var ServerExecuteDepth = cType.GetProperty("ServerExecuteDepth", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(this.Context, null);
            Response.Write("ServerExecuteDepth: " + ServerExecuteDepth.ToString());
            Response.Write("<br />");

            Response.Write("Context_Handler: " + (this.Context.Handler != null));
            Response.Write("<br />");


            var _fPageLayoutChanged = pType.GetField("_fPageLayoutChanged", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(this);
            Response.Write("_fPageLayoutChanged: " + _fPageLayoutChanged.ToString());
            Response.Write("<br />");

            Response.Write("base.GetType() != this.Context.Handler.GetType())) " + (base.GetType() != this.Context.Handler.GetType()));
        }

C# to VB

update

Since you can't get the values of the controls too, I suspect _requestValueCollection is null. _requestValueCollection is the collection of the posted values and query string values. Still this doesn't solve the problem..

Upvotes: 0

IrishChieftain
IrishChieftain

Reputation: 15253

Try setting the AutoEventWireup to true in the Page tag.

Upvotes: 0

Aristos
Aristos

Reputation: 66641

I do not understand one think. You have the AutoEventWireup to false, that means the PageLoad is not called, but you say that is called... wired... maybe some other class loaded, something is mix up here.

AutoEventWireup="false"

can you turn this to true to see the results ?

Upvotes: 0

Brady Holt
Brady Holt

Reputation: 2924

Looking at your page source once you postback I see:

IsPostBack : False on 2/10/2012 3:50:06 PM

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
...

How the heck is that "IsPostBack : False.." blurb being placed before your DOCTYPE. Check your Protected Sub Page_Load event handler and make sure it is correct syntax, etc. because it seems like it might be firing before it should and therefore not getting correct state of IsPostBack.

Upvotes: 0

Nikki9696
Nikki9696

Reputation: 6348

You don't have a click event to handle and it's working as a submit button instead, which won't generate postbacks.

http://www.w3schools.com/aspnet/prop_webcontrol_button_usesubmitbehavior.asp

Turn off submit behavior.

Upvotes: 0

Related Questions