标签: code-behind

替代在ASP.Net MVC视图中使用OnLoad事件?

我正在创建一个简单的测试应用程序,因此我可以看到ASP.Net MVC如何适用于我们每天处理的内容.我们使用Developer's Express的第三方控件,我们将继续使用它们.如果他们绝对不能在ASP.Net MVC中工作,那么我们就不会使用ASP.Net MVC.

话虽如此,有人找到了一种方法让它发挥作用.他只需要在代码中加入一些代码.他必须覆盖OnLoad事件,只需将grid.DataSource = model和grid.DataBind()放在一起就可以正常工作了.

在ASP.Net MVC RC中,消除了代码隐藏文件.我知道我可以把它们放回去......但是,由于人们通常说文件背后的代码是邪恶的,你还能做到这一点吗?

.net asp.net asp.net-mvc code-behind

2
推荐指数
1
解决办法
9969
查看次数

为DNN页面放置代码

我很难找到可以为我的dnn页面添加代码隐藏的地方.

例如:

MyPage.ascx已经有了

<%@ Control language="vb" CodeBehind="~/admin/Skins/skin.vb" AutoEventWireup="false" Explicit="True" Inherits="DotNetNuke.UI.Skins.Skin" %>
Run Code Online (Sandbox Code Playgroud)

为了塑造皮肤需要它.

但是,我希望能够添加在Page_Load上执行的VB函数,因此我创建了自己的代码隐藏文件.但我无法取出当前的控件(一个引用skin.vb)来放入我自己的控件,而且你不能拥有多个控件.

我也试过在代码中嵌入代码,但是我需要做一些Imports,它给我一个错误,说它们必须在文件的开头等声明等等...

任何人都知道如何正确添加DNN页面的代码隐藏?

vb.net asp.net dotnetnuke code-behind

2
推荐指数
1
解决办法
4055
查看次数

如何从ASP.NET中的代码绑定文件以编程方式在新选项卡中打开新页面?

在单击第一页中的按钮后,如何以编程方式从ASP.NET中的代码隐藏文件中以新选项卡打开页面?希望从新页面我也可以进入Session []数组.

asp.net code-behind

2
推荐指数
1
解决办法
2万
查看次数

如何在WPF中的多个类似按钮上处理点击事件?

我是C#初学者,我正在尝试在WPF中实现数字键盘.它由10个类似的按钮组成:

<Button Content="0" Name="button0" Click="anyButtonClicked" />
<Button Content="1" Name="button1" Click="anyButtonClicked" />
<Button Content="2" Name="button2" Click="anyButtonClicked" />
...
<Button Content="9" Name="button9" Click="anyButtonClicked" />
Run Code Online (Sandbox Code Playgroud)

处理所有这些按钮的最佳做法是什么?我是否在每个代码背后的代码中构建一个函数(这将主要是无聊并重复我自己),或者我是否构建一个函数来处理任何单击的按钮?

在第二种情况下,如何识别单击了哪个按钮?我需要访问哪些发件人对象的属性?

c# wpf code-behind

2
推荐指数
1
解决办法
4229
查看次数

从SharePoint 2010中的列表项上的自定义按钮/操作启动工作流(全部使用Visual Studio 2010)

我很抱歉问了一个双重问题,但我搞砸了找不到解决方案 - 或者对答案缺乏理解.

我的问题就像被描述一样:

我有一些带按钮的自制定制丝带.如果我点击设计按钮,我想开始工作流程.

好的,有关设置的更多信息:

这是一个通用列表,意思是,我的elemets.xml看起来像这样:

<CustomAction
  Id="MyCustomRibbonTab"
  Location="CommandUI.Ribbon.ListView"
  RegistrationId="100"
  RegistrationType="List">
  <CommandUIExtension>
    <CommandUIDefintions>
      <CommandUIDefinition
        Location="Ribbon.Tabs._children">
        <Tab Id="Ribbon.CustomTab" Sequence="501">
        ... (Scaling)
          <Groups Id="Ribbon.CustomTab.Groups">
            <Group 
              Id="Ribbon.CustomTab.GroupOne" 
              Sequence="52">
              <Controls Id="Ribbon.CustomTab.GroupOne.Controls">
                <Button
                  Id="Ribbon.CustomTab.GroupOne.ButtonOne"
                  Command="CustomTab.ButtonOneCommand"
                  Sequence="11">
              </Controls>
            </Group>
          </Groups>
        </Tab>
      </CommandUIDefinition>
    </CommandUIDefinitions>
    <CommandUIHandlers>
      <CommandUIHandler
        Command="CustomTab.ButtonOneCommand"
        CommandAction="javascript:alert('how start workflow here?');" />
        />
    </CommandUIHandlers>
  </CommandUIExtension>
  <!-- what about starting workflow here? How? -->
</CustomAction>
Run Code Online (Sandbox Code Playgroud)

希望很清楚我的XML-Post意味着什么.好吧,如果我把CommandAction ="javascript:alert('应该启动一个工作流程'),这样可以正常工作;" .我的意思是,这个警报弹出,我可以点击好,没别的.

现在我在同一个项目中设计了我的工作流程.有两种类型,一种在asp中有启动形式,另一种没有,都在选定的项目上运行.我可以在使用标准功能区"Workflows"时启动它们,然后单击它们.到目前为止一切都很好.

但我希望通过单击我的按钮来启动每个工作流程,而不是现在的点击次数.谢谢你到目前为止帮助我.

我是SharePoint的新手.所以请在你的答案中包括诸如"添加新的...空元素/ JavaScript文件"之类的内容或者任何必要的内容以获得我所假设的内容.

如果您对我的工作流程设计有更多疑问,我会尽快回答.

非常感谢你,

danbruc

注意:是的,我只是希望即使我的Elements.xml也没问题.我从网上拿走了所有.所以如果你有重新设计的建议,我是开放的.只是盲目地看到解决方案.另外,我可以把这个Tab放在ListView的ContextualTab中,但是后来甚至javascript都无法正常工作.

sharepoint workflow custom-action code-behind

2
推荐指数
1
解决办法
1万
查看次数

如何将jQuery函数放入我的代码后面?

我有下面的jQuery函数(Show_popupWindows):

    $(function () {
                        var popupWindows_Done = $('input[type="hidden"]#hfpopupWindows_Done').val();
                        if (popupWindows_Done == "false") {
                            Show_popupWindows();
                        }
                        else {
                        }
    });    //End Of $(function ()
    //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
                function Show_popupWindows() {
                    var x = screen.availWidth;
                    //alert(x);
                    $('div#OffDiv').css({ 'width': x });
                    //alert($('div#OffDivAndLoadingContainer').css('width'));
                    var y = screen.availHeight;
                    //alert(y);
                    $('div#OffDiv').css({ 'height': y });
                    //alert($('div#OffDivAndLoadingContainer').css('height'));

                    //alert('On');
                    $('div#OffDiv').css({ 'display': 'block' });
                    $('div#TimerContainer').css({ 'display': 'block' });

                    var w1 = window.open('http://www.blablabla.com', '_blank', 'channelmode=no,directories=yes,location=no,resizable=yes,titlebar=yes,menubar=no,toolbar=no,scrollbars=yes,status=yes', false);
                    var w2 = window.open('http://www.blablabla.com', '_blank', 'channelmode=no,directories=yes,location=no,resizable=yes,titlebar=yes,menubar=no,toolbar=no,scrollbars=yes,status=yes', false);
                    window.focus();

                    var sec = $('#TimerContainer span').text()
                    var timer …
Run Code Online (Sandbox Code Playgroud)

c# asp.net jquery code-behind

2
推荐指数
1
解决办法
2154
查看次数

保存数据asp.net后,在按钮单击时显示警报消息

我想在按钮单击上将记录保存到数据库之后显示消息"成功添加",该按钮单击已经具有JS功能以对数据进行一些验证.我尝试了以下代码,但没有显示任何内容.

ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert",
"<script>alert('" + "Successfully added" + "');</script>", false);
Run Code Online (Sandbox Code Playgroud)

如何在结束保存过程中在弹出窗口中显示成功消息?

javascript asp.net alert code-behind

2
推荐指数
1
解决办法
2万
查看次数

如何将onclick事件添加到gridview的第一列而不是整行?

标题非常明显.我有一个gridview,当用户点击一个特定的行时,我会在第一列添加一个阴影.问题是,用户可以单击行上的任何位置,并添加阴影,但只有当用户单击链接(即第一列)时,才会在新选项卡中打开链接.如何将onclick事件添加到每行的第一列?

    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        // Javascript function to call on row-click event
        e.Row.Attributes.Add("onClick", "javascript:void SelectRow(this);");
    }
Run Code Online (Sandbox Code Playgroud)

如果它有帮助,我使用这里的例子来实现SelectRow.

javascript c# gridview onclick code-behind

2
推荐指数
1
解决办法
3209
查看次数

RoutedEvent"该成员未被识别或无法访问"

我想使用一个自定义事件,而不是使用输入设备生成的事件,该事件将在我的xaml中作为EventTrigger在代码隐藏中以编程方式引发.
这应该是可笑的,但我无法在任何地方找到一个例子.

以下是我从学习WPF4 Unleashed第6章,路由事件实现,EventTrigger.RoutedEvent属性,自定义RoutedEvent作为EventTrigger以及其他许多内容中得出的结果:

MainWindow.xaml.cs:

namespace RoutedEventTrigger
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            RaiseEvent(new RoutedEventArgs(fooEvent, this));
        }
        public static readonly RoutedEvent fooEvent = EventManager.RegisterRoutedEvent(
        "foo", RoutingStrategy.Direct, typeof(RoutedEventHandler), typeof(MainWindow));

        // Provide CLR accessors for the event 
        public event RoutedEventHandler foo
        {
            add { AddHandler(fooEvent, value); }
            remove { RemoveHandler(fooEvent, value); }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

MainWindow.xaml:

MainWindow.xaml

PS请温柔,我对WPF比较新.

c# wpf xaml code-behind routed-events

2
推荐指数
1
解决办法
4861
查看次数

更改textblock中部分文本的颜色

我需要在后面的代码中更改颜色为文本字符串的一部分..

我的exaple:

textblock1.Text = string1 + string2 + string3;
Run Code Online (Sandbox Code Playgroud)

字符串有动态值,我希望在以蓝色运行程序后显示string2,并且必须在后面的代码中定义.

这是可能的?谢谢!

c# string wpf colors code-behind

2
推荐指数
2
解决办法
8956
查看次数