dropdownlist events does not show in properties wi

2020-08-09 09:53发布

I recently found that dropdownlist events are not shown in properties window. I was disappointed. I already hate asp.net designer in visual studio. its slow and full with ugly things like this. please help me. I need to generate events automatically not to write it by hand.

enter image description here

9条回答
闹够了就滚
2楼-- · 2020-08-09 10:17

Can't speak for earlier versions of VS, but for 2013, after adding the element, Build the project. Sometimes I have to switch to Design view and back to Source view once on the page, but then the events appear:

enter image description here

Click the lightning bolt icon for the events. Double click SelectedIndexChanged and it creates this in the codebehind:

    protected void ddlChoice_SelectedIndexChanged(object sender, EventArgs e) {

    }

And adds the event handler to the markup:

 <asp:DropDownList runat="server" ID="ddlChoice" OnSelectedIndexChanged="ddlChoice_SelectedIndexChanged" />
查看更多
看我几分像从前
3楼-- · 2020-08-09 10:21

Click on the 'Split' view in MS Visual Studio - select a button in the 'Design' view and then look into property window now. You should be able to see Events now. Good luck.

查看更多
神经病院院长
4楼-- · 2020-08-09 10:27

It seems that the Properties Dropdown changes after viewing 'Split' or 'Design' view of the .aspx file at least once. In my case, I always left it in 'Source' mode and never saw the asp.net properties (and events) in Properties Dropdown.

The Design/Split/Soruce buttons are in the lower left of the text editor window pane.enter image description here

查看更多
ゆ 、 Hurt°
5楼-- · 2020-08-09 10:28

I have found this too, only it happens on every control.

I found that if you are using "Source View", the events button is not shown in the properties window, but if you use design view and single click the control in design view (or "Both" view) then the events button is then shown in the properties window.

I suspect this is a bug in VS10? It's quite annoying as I don't like the Design view in VS, I always prefer Source view.

查看更多
Viruses.
6楼-- · 2020-08-09 10:28

At the top of your code page there are two comboboxes. Choose your dropdownlist from the one on the left (It says "(General)" by default) and then choose your event from the one on the right one.

It will create the event for you and so you can just add your code.

查看更多
神经病院院长
7楼-- · 2020-08-09 10:29

I haven't found a good answer for this anywhere on the web so here it is:

After playing around I noticed that the Events options in Properties disappears after you have started editing the file. If you save or Ctrl+s then Visual Studio will reevaluate the page and realize its an actual ASP tag and give you the full properties with the events choices again.

You do not have to use Designer.

查看更多
登录 后发表回答