سؤال

I am trying to create a togglebutton for a website with Microsoft Visual Studio and am not sure if this would be the correct code to apply. I am working in C#, so the button is going to be generated in C# (and a bit of jquery) code and eventually styled in CSS. This is my code:

// Toggle menu oToggleMenuControl
HtmlGenericControl oToggleMenuControl = new HtmlGenericControl("div");
oToggleMenuControl.Attributes.Add("class", "ToggleButton");
this.Controls.Add(oToggleMenuControl);

string sToggleButton = string.Format(@"
    $( '.ToggleButton' ).click(function () {
        $( '#RootTabRowMenu' ).toggle( 'slow', function() {
        });
    });"
);

Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "ToggleButton" 
    + sToggleButton, true);

It won't be flawless, since I'm a beginner at this. However, I have noticed at least one thing that doesn't work the way I intended it to work. The last line contains the "Page" class. It is not recognized and it won't turn green.

Can anyone tell me what I'm doing wrong or is there any other way to do this?

هل كانت مفيدة؟

المحلول

the correct code is without + but , near ToggleButton

Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "ToggleButton" , sToggleButton, true);
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top