[CLOSED] Pass parameter to ashx page

  1. #1

    [CLOSED] Pass parameter to ashx page

    Hello,
    I want to pass the value of a hidden field (hdnclientid) to an ashx page which I call from store:
    Markup:

    <ext:Hidden ID="hdnclientid" runat="server" />
                                                <ext:ComboBox ID="CmbInvestAdd" runat="server"
                                                    DisplayField="FullName"
                                                    ValueField="id"
                                                    TypeAhead="true"
                                                    FieldLabel="Investigator"
                                                    Width="470" MaxLength="150"
                                                    PageSize="10" AllowBlank="false"
                                                    LabelWidth="130" ForceSelection="true" 
                                                    HideTrigger="true"
                                                    MinChars="0"
                                                    TriggerAction="Query">
                                                    <ListConfig  LoadingText="Searching...">
                                                        <ItemTpl ID="ItemTpl6" runat="server">
                                                            <Html>
                                                                <div class="search-item">
                                                                    <h3>{LastName} {FirstName}</h3>
                                                                    {Speciality1}, {Address} - {City} &nbsp {Phone} 
                                                                </div>
                                                            </html>
                                                        </ItemTpl>
                                                    </ListConfig>
                                                    <Store>
                                                        <ext:Store ID="Store7" runat="server" AutoLoad="false" >
                                                            <Proxy>
                                                                <ext:AjaxProxy Url="~/SearchControls/DoctorSearch.ashx">
                                                                    <ActionMethods Read="POST" />
                                                                    <Reader>
                                                                        <ext:JsonReader RootProperty="Doc" TotalProperty="total" />
                                                                    </Reader>
                                                                       <ExtraParams>
                                                                            <ext:Parameter Name="clientid" Value="#{hdnclientid}.getValue()" Mode="Raw"/>
                                                                      </ExtraParams>
                                                                </ext:AjaxProxy>
                                                            </Proxy>
    ASHX file
    public void ProcessRequest(HttpContext context)
            {
                context.Response.ContentType = "text/json";
    
                var clientid = context.Request["clientid"];
    But I receive this js error:
    Uncaught TypeError: Cannot read property 'getValue' of undefined
    Last edited by fabricio.murta; Mar 10, 2017 at 5:28 PM.
  2. #2
    Hello @atroul!

    Your markup code line 33, the way you set it, it will be resolved at page first load, not when the parameter is submitted. You have to wrap the #{hdnclientid}.getValue() code in a function. I think it will also not work the reference the way you did with #{}. You may try it, but I believe you'd have to change it to App.hdnclientid.

    The Value= attribute should look like something like this:

    Value="function() { return App.hdnclientid.getValue(); }"
    Hope this helps!
    Fabrício Murta
    Developer & Support Expert
  3. #3
    Hello Fabricio,
    Thanks for the fast response
    I tried what you proposed:
    <ext:Parameter Name="clientid" Value="function() { return App.hdnclientid.getValue(); }" Mode="Value"/>
    I tried both Value and Raw for Mode
    But in the Handler page clientid's value is:
    "function () { return App.hdnclientid.getValue(); }"
    Last edited by atroul; Feb 15, 2017 at 3:37 PM.
  4. #4
    Hello again!

    Please double check, as the mode should be Raw. With Mode="Raw" you shouldn't be getting the clientid value on the ashx as the function literal text, but what it returns each time the ashx is called. If you are getting this then there must be a problem with some kind of cache, try a force refresh. Your line 33 must read something like this:

    <ext:Parameter Name="clientid" Value="function() { return App.hdnclientid.getValue(); }" Mode="Raw" />
    I didn't mention the rest of the line in hopes you wouldn't change them.

    Hope now this helps!
    Fabrício Murta
    Developer & Support Expert
  5. #5
    No I didn't change anything else. I checked also with Raw mode and with force refresh
    but still not working. Same results
  6. #6
    Hello, @atroul!

    Interesting, it should work. There *must* be something missing there, or here. So, please, can you provide a runnable test case, maybe based in one example in our examples explorer, so we could build the page exactly as yours and run it in our side?

    Maybe I couldn't notice something obvious on your code, so running it from our side would be best to help you with this!

    If you are not certain on where to begin, I believe this example would be a good starting point to illustrate your issue: Loader - Component via HTTP Handler
    Fabrício Murta
    Developer & Support Expert
  7. #7
    Well I manage to solve it by moving the line:
    <ext:Hidden ID="hdnclntid" runat="server" Text="0" />
    Before this line:
    <ext:FormPanel runat="server" ID="frmPanAddUsers">
    Any thoughts why it was affecting it? All the other Hidden Fields are declared
    after the FormPanel declaration and they work....
  8. #8
    Hello @atroul!

    Hard to say, this is the first time you ever mentioned this line, no? Again, knowing how you built your case is fundamental on being able to provide you consistent feedback and advice. That's why the test case was requested in the first place.

    Please consider reviewing our guidelines on posting new threads and simplified test cases so that in the next issues we can actually know what's happening and be able to help you. As your last post suggests, at least part of the problem was related to an artifact you didn't provide at all. Here are the forum threads:

    1. More Information Required
    2. Forum Guidelines
    3. Tips for creating simplified code samples

    I hope you understand, we want to help, but we need the right information before we can understand your problem and provide you with best support! :)
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. Pass a parameter to a controller
    By kdms in forum 3.x Help
    Replies: 9
    Last Post: Feb 27, 2015, 12:31 PM
  2. DirectMethod - how to pass an array parameter
    By tcunha in forum 2.x Help
    Replies: 3
    Last Post: May 21, 2014, 10:17 AM
  3. [CLOSED] How to pass parameter when using HttpWriteProxy
    By Daly_AF in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Apr 16, 2012, 9:46 PM
  4. Pass Parameter to store at runtime
    By Vaishali in forum 1.x Help
    Replies: 0
    Last Post: Feb 07, 2012, 6:58 AM
  5. How to pass object as a parameter?
    By diegovbs in forum 1.x Help
    Replies: 1
    Last Post: Jan 04, 2011, 5:53 PM

Tags for this Thread

Posting Permissions