无效的回发或回调参数

发布于 2024-11-27 23:33:41 字数 3697 浏览 3 评论 0原文

当我使用下拉列表附加特定数据源时,我遇到此错误。与所有其他表/数据源一起工作正常。 我没有使用 javascript/jquery 对下拉列表进行任何更改(因为它可以与除当前之外的所有其他数据源一起正常工作)

错误:

无效的回发或回调参数。事件验证是

在配置中启用 或 <%@ Page EnableEventValidation="true" %>在一个页面中。为了安全 目的,此功能验证回发或回调的参数 事件源自最初呈现的服务器控件 他们。如果数据有效且符合预期,请使用 ClientScriptManager.RegisterForEventValidation 方法以便 注册回发或回调数据以进行验证。

我从 xml 文件获取值的函数:

public List<ProductReviewmaster> ConvertRssXDocToReviews(XDocument xdoc)
{
    List<ProductReviewmaster> nl = new List<ProductReviewmaster>();

    if (xdoc != null)
    {
        var res = from rs in xdoc.Descendants("item")
                  select new ProductReviewmaster()
                  {
                      Title = rs.Element("title").Value,
                      ShortHeadLine = rs.Element("shortheadline").Value,
                      Link = rs.Element("link").Value,
                      Reviewid = rs.Element("guid").Value ,
                      //Pubdate = Convert.ToDateTime( rs.Element("pubdate").Value),
                      Image = rs.Element("storyimage").Value,
                      Dateline = rs.Element("dateline").Value,
                      Excerpt = rs.Element("excerpt").Value,
                      Tags = rs.Element("tags").Value,
                      ProductId = rs.Attribute("productid").Value.ToInt64()
                  };
        foreach (var item in res)
        {
            nl.Add(item);

        }
    }
    return nl;


}

这​​就是我将其与下拉列表绑定的方式:

   ddlReview.DataSource =  prmf.GetReviewByCategoryKey(categoryid);
                ddlReview.DataValueField = "Reviewid";
                ddlReview.DataTextField = "Title";
                ddlReview.DataBind();
                ddlReview.Items.Insert(0, new ListItem("---Select---"));

当我将相同的下拉列表与任何其他数据源(非 xml)绑定时,它工作正常..但是当我使用此数据源执行此操作时,它会抛出异常上面那个错误。

我的 xml 就像:

<rss version="2.0">
  <channel>
    <title>

        </title>
    <link>

        </link>
    <language>en</language>
    <lastBuildDate>
            August  3, 2011  3:57 PM
        </lastBuildDate>
    <image>
      <url></url>
      <link>
            </link>
    </image>
    <items>
      <item productid="">
        <title><![CDATA[This is new test review]]></title>
        <shortheadline><![CDATA[]]></shortheadline>
        <link>

                    </link>
        <permaLink>
          <web>

                        </web>
        </permaLink>
        <guid isPermaLink="false">
                        29527
                    </guid>
        <pubDate>
                        August  2, 2011  1:56 PM
                    </pubDate>
        <MobileText></MobileText>
        <storyimage><![CDATA[ges/apple-appstore.jpg]]></storyimage>
        <categories><![CDATA[mobile]]></categories>
        <dateline><![CDATA[]]></dateline>
        <excerpt><![CDATA[isational structure for its operations in India and South Asia with effetransformational business...]]></excerpt>
        <tags><![CDATA[mobile, phone]]></tags>
        <contenttype><![CDATA[Review]]></contenttype>
      </item>
    </items>
    <description></description>
  </channel>
</rss>

它成功检索数据并显示在下拉列表中,但是当我从中选择任何项目(所选索引已更改)时,它会显示此消息...

谢谢

I am facing this error when i attach specific datasource with dropdownlist. with all other tables/datasources its working fine.
I am not doing any changes in dropdownlist using javascript/jquery (as its working fine with all other datasource except current)

error:

Invalid postback or callback argument.  Event validation is

enabled using in configuration
or <%@ Page EnableEventValidation="true" %> in a page. For security
purposes, this feature verifies that arguments to postback or callback
events originate from the server control that originally rendered
them. If the data is valid and expected, use the
ClientScriptManager.RegisterForEventValidation method in order to
register the postback or callback data for validation.

my function to get values from xml files:

public List<ProductReviewmaster> ConvertRssXDocToReviews(XDocument xdoc)
{
    List<ProductReviewmaster> nl = new List<ProductReviewmaster>();

    if (xdoc != null)
    {
        var res = from rs in xdoc.Descendants("item")
                  select new ProductReviewmaster()
                  {
                      Title = rs.Element("title").Value,
                      ShortHeadLine = rs.Element("shortheadline").Value,
                      Link = rs.Element("link").Value,
                      Reviewid = rs.Element("guid").Value ,
                      //Pubdate = Convert.ToDateTime( rs.Element("pubdate").Value),
                      Image = rs.Element("storyimage").Value,
                      Dateline = rs.Element("dateline").Value,
                      Excerpt = rs.Element("excerpt").Value,
                      Tags = rs.Element("tags").Value,
                      ProductId = rs.Attribute("productid").Value.ToInt64()
                  };
        foreach (var item in res)
        {
            nl.Add(item);

        }
    }
    return nl;


}

This is how i am binding it with my dropdownlist:

   ddlReview.DataSource =  prmf.GetReviewByCategoryKey(categoryid);
                ddlReview.DataValueField = "Reviewid";
                ddlReview.DataTextField = "Title";
                ddlReview.DataBind();
                ddlReview.Items.Insert(0, new ListItem("---Select---"));

When i bind same dropdownlist with any other datasource (non-xml) its working fine .. but when i am doing it with this datasource its throwing that above error.

My xml is like:

<rss version="2.0">
  <channel>
    <title>

        </title>
    <link>

        </link>
    <language>en</language>
    <lastBuildDate>
            August  3, 2011  3:57 PM
        </lastBuildDate>
    <image>
      <url></url>
      <link>
            </link>
    </image>
    <items>
      <item productid="">
        <title><![CDATA[This is new test review]]></title>
        <shortheadline><![CDATA[]]></shortheadline>
        <link>

                    </link>
        <permaLink>
          <web>

                        </web>
        </permaLink>
        <guid isPermaLink="false">
                        29527
                    </guid>
        <pubDate>
                        August  2, 2011  1:56 PM
                    </pubDate>
        <MobileText></MobileText>
        <storyimage><![CDATA[ges/apple-appstore.jpg]]></storyimage>
        <categories><![CDATA[mobile]]></categories>
        <dateline><![CDATA[]]></dateline>
        <excerpt><![CDATA[isational structure for its operations in India and South Asia with effetransformational business...]]></excerpt>
        <tags><![CDATA[mobile, phone]]></tags>
        <contenttype><![CDATA[Review]]></contenttype>
      </item>
    </items>
    <description></description>
  </channel>
</rss>

its successfully retriving data and showing on dropdownlist but when i select any item from it (selected index changed) then it shows this message...

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

So尛奶瓶 2024-12-04 23:33:41

当您的输入元素(包括下拉列表)包含这些字符“<”时,通常会出现该错误或“>”。

您是否尝试过对这些值(如果存在)进行编码?

That error usually crops up when your input elements, including drop downlists, contains either of these characters '<' or '>'.

Have you tried encoding those values if they exist?

最笨的告白 2024-12-04 23:33:41

最后我解决了这个问题...
在使用 LINQ 时,我只是使用了 Trim() 并完成了...:)

var res = from rs in xdoc.Descendants("item")
                          select new ProductReviewmaster()
                          {
                              Title = rs.Element("title").Value.Trim(),
                              ShortHeadLine = rs.Element("shortheadline").Value.Trim(),
                              Link = rs.Element("link").Value.Trim(),
                              Reviewid = rs.Element("guid").Value.Trim() ,
                              //Pubdate = Convert.ToDateTime( rs.Element("pubdate").Value),
                              Image = rs.Element("storyimage").Value.Trim(),
                              Dateline = rs.Element("dateline").Value.Trim(),
                              Excerpt = rs.Element("excerpt").Value.Trim(),
                              Tags = rs.Element("tags").Value.Trim(),
                              ProductId = rs.Attribute("productid").Value.ToInt64()
                          };

所以我的最终结论是一定存在带有值的空白空间问题...

Finally i resolved the issue...
while using LINQ, i just used Trim() and its done... :)

var res = from rs in xdoc.Descendants("item")
                          select new ProductReviewmaster()
                          {
                              Title = rs.Element("title").Value.Trim(),
                              ShortHeadLine = rs.Element("shortheadline").Value.Trim(),
                              Link = rs.Element("link").Value.Trim(),
                              Reviewid = rs.Element("guid").Value.Trim() ,
                              //Pubdate = Convert.ToDateTime( rs.Element("pubdate").Value),
                              Image = rs.Element("storyimage").Value.Trim(),
                              Dateline = rs.Element("dateline").Value.Trim(),
                              Excerpt = rs.Element("excerpt").Value.Trim(),
                              Tags = rs.Element("tags").Value.Trim(),
                              ProductId = rs.Attribute("productid").Value.ToInt64()
                          };

so my final conclusion is there must me problem of blank space with value...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文