DNNDev.com Forums Minimize
Passing variable through URL
Last Post 31 Oct 2011 06:57 PM by DNNDev Admin. 1 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
lmattox
New Member
New Member
Posts:9
Avatar

--
31 Oct 2011 06:41 PM  
I find myself creating a lot of "duplicate" feeds where the only thing I am changing is the number following WHERE in the SQL query. For example I will do ten feeds, "WHERE Company=1", "WHERE Company=2" and so on.

Would there be any way of passing that value through the URL. So I could create one feed and just change the number in the URL?

For example, the URL might be: http://www.mysource.coop/DesktopModules/XModPro/Feed.aspx?xfd=Communications&company=2&pid=32

I think this may eliminate a lot of redundant work. Is something like this possible now, or might it be in a future release?
DNNDev Admin
Senior Member
Senior Member
Posts:6419
Avatar

--
31 Oct 2011 06:57 PM  
Hi lmattox,

Sure. It's possible now.

In your feed's ListDataSource tag, add a Parameter to grab the URL param value. Example:


<xmod:Feed>
  <ListDataSource CommandText="SELECT * FROM Companies WHERE CompanyId=@cid">
    <Parameter Name="cid" Value='[[Url:cid]]' DataType="Int32" />
  </ListDataSource>
  ...
</xmod:Feed>


It is good practice to specify the DataType for parameters - especially those that can be user-supplied. So, in this case you're ensuring the passed-in value is a number. This helps prevent scripting attacks.



Best,
Kelly
Power Your Website With XMod Pro
Buy XMod Pro Today
You are not authorized to post a reply.

Active Forums 4.1
spacer
dummy