开发者

Change the property "DefaultValue" of the asp.net "ControlParameter" control with javascript

开发者 https://www.devze.com 2022-12-11 22:15 出处:网络
I already have an idea on how to do this, but I realized that the control \"ControlParameter\" did not have an \"Id\" property (which is needed for the JS). Is there a different way to use JavaScript

I already have an idea on how to do this, but I realized that the control "ControlParameter" did not have an "Id" property (which is needed for the JS). Is there a different way to use JavaScript to change the "DefaultValue" property without the need of using the "Id" property?

Here is the JavaScript and asp.net code that I have been working with:

JavaScript:

        function ChangePropertyValue(propertyName, newpropertyValue) {
        var ControlParameter = document.getElementById(propertyName)
        ControlParameter.DefaultValue = newpropertyValue
    }

asp.net:

        <asp:Button ID="btntest" runat="server" Text="try" OnClick="ChangePropertyValue(??, 17)"/>

        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:DatabaseConnectionString1 %>" 
        SelectCommand="SELECT [Id], [ContentTitle], [Content] FROM [Table1] WHERE ([Id] = @Id)">
        <SelectParameters>
            <asp:ControlParameter ControlID="ListView1" DefaultValue="16" Name="Id" 
                PropertyName="Select开发者_如何学CedValue" Type="Int32"/>
        </SelectParameters>
    </asp:SqlDataSource>


You can't access a ControlParameter client side. ControlParameters are used to bind the value of a Control property server side, they are not rendered to the client. You can, however, set the Default value of the ControlParameter programmatically in your Code Behind.

SqlDataSource1.SelectParameters["id"].DefaultValue = "value";
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号