Good day!

I have a DVWP. DVWP has parameters as query string "StartDate" and "DateEnd" and filters on datefield "Date" by parameters "StartDate" and "EndDate".

Also I have form on the page with javascript.

 function getparam()
 var startdate = document.getElementById("datepicker").value;
 var enddate = document.getElementById("datepicker").value;
 var date = startdate.split("-");
 var stringstart = date[2]+"-"+date[1]+"-"+ date[0]+"T00:00:00Z";
 date = enddate.split("-");
 var stringend = date[2]+"-"+date[1]+"-"+ date[0]+"T23:59:59Z";
 var strUrl = window.location.toString()+"?StartDate="+stringstart+"&EndDate="+stringend;

      <div id="panelDay" style="display:block;">            
         Choose Date: <input type="text" id="datepicker"/><br/> 
         <input name="Button1" type="button" value="button" onclick="getparam()" /> 

I'm not sure if i prepared the query string "strUrl" right.

Question: How can I send theese parameters to DVWP, so DVWP will be filtered?

I tried this if( PreSaveAction() ) {ddwrt:GenFireServerEvent('__redirect(strUrl)')}; but it doesn't work for me.

(And i don't want to use DateFilter WP for some reasons)

Updated So I did This

  __doPostBack('ctl00$m$g_3375d095_c73e_4b32_86b1_d90170c4f5e2','NotUTF8;StartDate={'+ stringstart  +'};EndDate={'+ stringend + '}');

But I had to change my parameters from "QueryString" to "Postback;Connection;" and it works now. But I still can't figure out how should i use doPostBack with Query string paramters. Should I use redirect?so i can see HTML code of this __doPostBack

 ddwrt:GenFireServerEvent('__commit;__redirect={http://myadd/sites/redirect.aspx?StartDate= stringstart&EndDate=stringend}') 

I think you have to trigger the new Request. My solution would be to Request __doPostBack and handle your Params via the Request properties. In your case it would be:

var dates = new Array();
dates [0] = stringstart;
dates [1] = stringend;
__doPostBack("Button1", dates );

In the code himself these could be accessed by:

  • Thank you for answer. I'm not very good in english. Could you explain what did you mean in last sentence? – Lena Sep 12 '12 at 10:07
  • In case of __doPostBack you'll send the information with an hidden field, not with the Querystring, so in the codebehind (or where ever you're analyzing the querystring). The values of the dates are stored in the hidden field, which is auto-generated by asp. In code behind the call var x = Request["__EVENTARGUMENT"]; will cause x to have the dates inside. – Maikm88 Sep 12 '12 at 12:48

In the case you have to do it via Querystring you can.

var strUrl = window.location.toString()+"?StartDate="+stringstart+"&EndDate="+stringend;
window.location = strUrl;

This should redirect the user to your site and make the params available in the querystring.

  • Thank you, but I tried this already. User redirects on the same page but witout query string parameters, like it was cut somehow... I guess i should do doPostback anyway... – Lena Sep 20 '12 at 12:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.