- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这是我的按钮的 aspx 代码:
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
下面是代码隐藏文件中的 onclick 事件函数:
public void Button1_Click(object sender, EventArgs e)
{
lblOutput.Text = txtFirstName.Text;
}
或者,我还在 onclick 函数中使用了它,以查看问题是否出在函数中的脚本而不是按钮本身:
public void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("http://www.google.com");
}
不幸的是,这也不起作用。所以问题可能是点击按钮时出了问题,对吧?
后面的代码已正确链接,因为 page_load 中的其他函数工作正常。
单击我的按钮时发生的所有事情是页面刷新。老实说,我不确定我是否可以称之为刷新,from 中的值仍然存在,页面只是跳回顶部,没有其他任何事情发生。
我还尝试创建第二个按钮,其 ID 和 onclick 名称略有不同,但页面的行为仍然相同。我在这里完全不知所措。我没有在谷歌上找到任何有帮助的东西。
编辑:这是完整的 asp 文件。我们将 ektron 用作 CMS,因此也有一些奇怪的代码。在任何人询问之前,是的,它在表单标签中。
<%@ Page Language="C#" MasterPageFile="~/InteriorPage.master" AutoEventWireup="true" CodeFile="urmintakeform.cs" Inherits="urmintakeform" Debug="true" %>
<%@ Register Assembly="Ektron.Cms.Controls" Namespace="Ektron.Cms.Controls" TagPrefix="CMS" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<asp:Literal ID="Literal1" runat="server" />
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="PageBody" Runat="Server">
<div id="two-column-pagenav" class="section-divider-small">
<div class="column-one"><h2>University Relations and Marketing</h2></div>
<div class="column-two">
<p class="breadcrumb">
<CMS:FolderBreadcrumb ID="FolderBreadcrumb1" runat="server" DynamicParameter="id" SuppressWrapperTags="true" SuppressAddEdit="true" />
</p>
</div>
</div>
<div>
<img alt="URM Banner" src="/images/department_banners/urm-banner.jpg" />
<asp:Literal ID="litDeptImage" runat="server" />
</div>
<div id="" class="container section-divider-small">
<div class="column-one">
<div class="nav-aside widget">
<div class="opener-block">
<a href="#" class="opener"><span>Menu</span></a>
<span class="title">University Relations and Marketing</span>
</div>
<div class="nav-page-box nav-slide">
<!--Replace this code with the Ektron Flex Menu Control-->
<CMS:FlexMenu ID="FlexMenu1" runat="server" SuppressAddEdit="true" DefaultMenuID="15032386736" DisplayXslt="xml/departments.xsl" SuppressWrapperTags="true" CacheInterval="0" AllowClose="true" EnableSmartOpen="True" AutoCollapseBranches="True" StartCollapsed="True" />
</div>
</div>
<div class="widget-holder">
<div class="dept-contact-box widget">
<h4>How to Reach Us</h4>
<p><span style="font-weight: bold">University Relations and Marketing</span><br />
xxxx<br />
xxxx<br />
xxxxx<br />
xxxx<a href="tel:xxxxxxxxxxxxxxxxxxxxxxx</a><br />
Email: <a href="xxxxxxxxxxxxxxxxxxxxx">xxxxxxxxxxxxxxxxxxx</a><br />
</p>
<div class="dept-social-media">
<a title="Twitter" href="xxxxxxxxxxxxxxx" target="_blank">
<img src="/images/socmed_icons/twitter-32x432.png" alt="Twitter" title="Twitter" />
</a>
</div>
</div>
</div>
</div>
<div id="body-content" class="column-two">
<div class="content-body">
<div id="ctl00_PageBody_ContentBlock1" class="content-container">
<div class="content-holder">
<asp:Literal ID="litInPageTopNav" runat="server" />
<asp:Literal ID="ltrContent" runat="server" />
<CMS:FormBlock ID="FormBlock1" runat="server" DynamicParameter="ekfrm" />
</div>
</div>
<div class="intake">
<h2>Tell us about yourself</h2>
<div class="userinfo">
<label id="firstname" runat="server" text="First Name:" >First Name:</label>
<asp:TextBox ID="txtFirstName" runat="server" MaxLength="50" placeholder="First Name"></asp:TextBox><p></p>
<label id="lblLastName" runat="server" text="">Last Name:</label>
<asp:TextBox ID="txtLastName" runat="server" MaxLength="50" placeholder="Last Name"></asp:TextBox><p></p>
<label id="lblDepartment" runat="server" text="">Department:</label>
<asp:TextBox ID="txtDepartment" runat="server" MaxLength="50" placeholder="Department"></asp:TextBox><p></p>
</div>
<!-- Phone and Email --------->
<div class="job">
<label id="lblPhone" runat="server" text="">Phone:</label>
<asp:TextBox ID="txtPhone" runat="server" MaxLength="50" placeholder="Phone"></asp:TextBox><p></p>
<label id="lblEmail" runat="server" text="Email">Email:</label>
<asp:TextBox ID="txtEmail" runat="server" MaxLength="50" placeholder="Email"></asp:TextBox><p></p>
</div>
<div style="clear:both;"></div>
<div class="help">
<h2>How can we help you?</h2>
<label id="lblCategory" runat="server" text="Help">Get Help With: </label>
<select name="areaselector" id="areaselector">
<option value="select">Select an Option</option>
<option value="design">Design</option>
<option value="imprinted">Imprinted</option>
<option value="photography">Photography</option>
<option value="social">Social Media</option>
<option value="written">Written Content</option>
</select>
<div id="design" class="areas" style="display:none" onchange="">
<asp:CheckBoxList ID="designASP" runat="server" OnSelectedIndexChanged="appendToSelectedList">
<asp:ListItem Value="brochures">Brochures</asp:ListItem>
<asp:ListItem Value="posters">Posters</asp:ListItem>
<asp:ListItem Value="postcards">Postcards</asp:ListItem>
<asp:ListItem Value="booklets">Booklets</asp:ListItem>
<asp:ListItem Value="advertisement">Advertisement Design</asp:ListItem>
<asp:ListItem Value="digitalMarketing">Digital Marketing Material</asp:ListItem>
<asp:ListItem Value="other">Other Promotional Material</asp:ListItem>
</asp:CheckBoxList>
</div>
<div id="imprinted" class="areas" style="display:none">
<asp:CheckBoxList ID="imprintedASP" runat="server" OnSelectedIndexChanged="appendToSelectedList">
<asp:ListItem Value="licensed vendors">Licensed Vendors</asp:ListItem>
<asp:ListItem Value="Imprinted product search/sample products">Imprinted product search/sample products</asp:ListItem>
<asp:ListItem Value="billboard leasing">Billboard Leasing</asp:ListItem>
<asp:ListItem Value="Imprinted product art/design">Imprinted product art/design</asp:ListItem>
<asp:ListItem Value="table covers">Table covers</asp:ListItem>
<asp:ListItem Value="retractable banners">Retractable banners</asp:ListItem>
<asp:ListItem Value="temporary signage">Temporary signage</asp:ListItem>
<asp:ListItem Value="tigerizing">"Tigerizing"</asp:ListItem>
</asp:CheckBoxList>
</div>
<div id="photography" class="areas" style="display:none">
<asp:CheckBoxList ID="photographyASP" runat="server" OnSelectedIndexChanged="appendToSelectedList">
<asp:ListItem Value="Official faculty and staff portraits">Official facutly and staff portraits</asp:ListItem>
<asp:ListItem Value="Groups and/or organizatoin portraits">Groups and/or organization Portraits</asp:ListItem>
<asp:ListItem Value="Organization Event photos">Organization Event photos</asp:ListItem>
<asp:ListItem Value="Student Event photos">Student Event photos</asp:ListItem>
<asp:ListItem Value="Departmental brochure and web photos">Departmental brochure and web photos</asp:ListItem>
<asp:ListItem Value="Sporting events">Sporting events</asp:ListItem>
<asp:ListItem Value="Guest speakers">Guest speakers</asp:ListItem>
<asp:ListItem Value="ID and/or nametags">ID and/or nametags</asp:ListItem>
<asp:ListItem Value="Visa\passports photographs">Visa\passports photographs</asp:ListItem>
<asp:ListItem Value="Scanning, retouching and custom printing">Scanning, retouching and custom printing</asp:ListItem>
<asp:ListItem Value="Archive/history FHSU image retrieval">Archive/history FHSU image retrieval</asp:ListItem>
</asp:CheckBoxList>
</div>
<div id="social" class="areas" style="display:none">
<asp:CheckBoxList ID="socialASP" runat="server" OnSelectedIndexChanged="appendToSelectedList">
<asp:ListItem Value="Training">Training</asp:ListItem>
<asp:ListItem Value="Event coverage">Event coverage</asp:ListItem>
<asp:ListItem Value="Marketing/promotion">Marketing/Promotion</asp:ListItem>
</asp:CheckBoxList>
</div>
<div id="written" class="areas" style="display:none">
<asp:CheckBoxList ID="writtenASP" runat="server" OnSelectedIndexChanged="appendToSelectedList">
<asp:ListItem Value="Print">Print</asp:ListItem>
<asp:ListItem Value="Web">Web</asp:ListItem>
</asp:CheckBoxList>
</div>
</div>
<div class="tellusmore">
<h2>Tell us more about your request</h2>
<asp:TextBox ID="tellUsMoreBox" TextMode="MultiLine" runat="server" Columns="50" Rows="6" />
</div>
<!--<asp:Button ID="btnSubmit" runat="server" Text="Submit Application" Enabled="true" CssClass="submit" onclick="btnSubmit_Click" />
<asp:Button ID="asdf" runat="server" Text="Submit Application" Enabled="true" CssClass="submit" OnClick="btnSubmit_Click" />-->
<asp:Label ID="lblOutput" runat="server" Text=""></asp:Label>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" CausesValidation="false"/>
</div>
</div>
</div>
</div>
</asp:Content>
这是 C# 文件:
protected void Page_Load(object sender, EventArgs e)
{
ContentBlock ContentBlock1 = new ContentBlock();
ContentBlock1.SuppressWrapperTags = true;
ContentBlock1.DefaultContentID = 64;
ContentBlock1.DynamicParameter = "id";
ContentBlock1.Page = this.Page;
ContentBlock1.Fill();
//this.ltrContent.Text = ContentBlock1.Text.Replace("width", "max-width");
string lsContent = ContentBlock1.Text.Replace("width:", "max-width:");
lsContent = lsContent.Replace("width=", "max-width=");
//this.ltrContent.Text = lsContent;
//this.ContentBlock1.Text = lsContent;
FolderBreadcrumb1.Text += " > <a href=\"" + ContentBlock1.EkItem.QuickLink + "\" class=\"active-link\">" + new CultureInfo("en").TextInfo.ToTitleCase(Server.HtmlDecode(ContentBlock1.EkItem.Title)) + "</a>";
// dynamically generate an image if it been added as a meta image selector
Ektron.Cms.CustomAttributeList ContentMetaData;
ContentMetaData = ContentBlock1.GetMetaData();
if (ContentMetaData.GetItemByName("department-image").Value.ToString().Length > 0)
{
string extension;
extension = Path.GetExtension(Convert.ToString(ContentMetaData.GetItemByName("department-image").Value));
string ext = extension.Substring(0, 4);
if (ext == ".swf")
{
//is flash
litDeptImage.Text = "<object id=\"myId\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"730\" height=\"175\">";
litDeptImage.Text += " <param name=\"movie\" value=\"" + Convert.ToString(ContentMetaData.GetItemByName("department-image").Value) + "\" />";
litDeptImage.Text += " <!--[if !IE]>-->";
litDeptImage.Text += " <object type=\"application/x-shockwave-flash\" data=\"" + Convert.ToString(ContentMetaData.GetItemByName("department-image").Value) + "\" width=\"730\" height=\"175\">";
litDeptImage.Text += " <!--<![endif]-->";
litDeptImage.Text += " <div>";
litDeptImage.Text += " <p>You have javascript turned off or are not running the latest version of Adobe Flash Player. To best view this site, please <a href=\"http://www.adobe.com/go/getflashplayer\"><img src=\"http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif\" alt=\"Get Adobe Flash player\" /></a></p>";
litDeptImage.Text += " </div>";
litDeptImage.Text += " <!--[if !IE]>-->";
litDeptImage.Text += " </object>";
litDeptImage.Text += " <!--<![endif]-->";
this.litDeptImage.Text += "</object>";
}
else
{
//else image
litDeptImage.Text = "<img class=\"ImageInline\" src=\"" + Convert.ToString(ContentMetaData.GetItemByName("department-image").Value) + "\" alt=\" \" />";
}
}
//grab collection id from the folder id that the content block belongs to
Ektron.Cms.API.Content.Content apiContent = new Ektron.Cms.API.Content.Content();
Ektron.Cms.Content.EkContent ekContent = apiContent.EkContentRef;
Microsoft.VisualBasic.Collection colldat = ekContent.GetAllCollectionsInfo(ContentBlock1.EkItem.FolderId, "id");
string collid = null;
foreach (Microsoft.VisualBasic.Collection field in colldat)
{
collid = field[1].ToString(); // collection id
}
long collint = Convert.ToInt64(collid);
//create the collection object we'll be using to get department nav pages
Ektron.Cms.Controls.Collection coll = new Collection();
coll.DefaultCollectionID = collint;
// set the standard coll properties
coll.DisplayXslt = "xml/departments-nav.xsl";
// attatch it to our invisible literal and fill it
coll.Page = Page;
coll.Fill();
if (!String.IsNullOrEmpty(collid))
litInPageTopNav.Text = coll.Text;
//Use the meta data we grabbed earlier to display title, keywords and description
Literal1.Text = "<title>" + Convert.ToString(ContentMetaData.GetItemByName("Title").Value) + " - xxxxxx University</title>\n";
Literal1.Text += "<meta name=\"keywords\" content=\"" + Convert.ToString(ContentMetaData.GetItemByName("Keywords").Value) + "\">\n";
Literal1.Text += "<meta name=\"description\" content=\"" + Convert.ToString(ContentMetaData.GetItemByName("Description").Value) + "\">\n";
//lblOutput.Text = Output;
}
public void Button1_Click(object sender, EventArgs e)
{
lblOutput.Text = txtFirstName.Text;
}
编辑 2: 这是在运行时查看页面源时页面上的标签,我相信可能是由主文件提供的。正如我之前所说,我们使用 ektron cms。表单标签会不会有问题?
<form method="post" action="/urm/intake/" id="aspnetForm" onsubmit="if('undefined' == typeof Ektron || !Ektron.FormBlock || !typeof Ektron.FormBlock.validate || Ektron.FormBlock.validate(this)){$ektron('input[type=submit]').attr('disabled','disable');return true;}else{return false;}">
最佳答案
想通了。 CMS 是错误的。我正在使用 Ektron CMS 提供的 URL 在线查看页面。更改模板
<CMS:FormBlock ID="FormBlock1" runat="server" DynamicParameter="ekfrm" />
到内容 block 固定它。 ektron CMS 中的表单 block 导致了问题。
关于c# - ASP :button onclick doesn't fire and page only refreshes,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38750789/
我对这个错误很困惑: Cannot implicitly convert type 'System.Func [c:\Program Files (x86)\Reference Assemblies\
考虑这段代码: pub trait Hello { fn hello(&self); } impl Hello for Any { fn hello(&self) {
问题很简单。是否可以构造这样一个类型 T,对于它下面的两个变量声明会产生不同的结果? T t1 = {}; T t2{}; 我已经研究 cppreference 和标准一个多小时了,我了解以下内容:
Intellij idea 给我这个错误:“Compare (T, T) in Comparator cannot be applied to (T, T)” 对于以下代码: public class
任何人都可以告诉我 : n\t\t\t\t\n\t\t\t 在以下来自和 dwr 服务的响应中的含义和用途是什么. \r\n\t\t\t \r\n\t\t\t
让 T 成为一个 C++ 类。 下面三个指令在行为上有什么区别吗? T a; T a(); T a = T(); T 为不带参数的构造函数提供了显式定义这一事实是否对问题有任何改变? 后续问题:如果
Rust中的智能指针是什么 智能指针(smart pointers)是一类数据结构,是拥有数据所有权和额外功能的指针。是指针的进一步发展 指针(pointer)是一个包含内存地
比如我有一个 vector vector > v={{true,1},{true,2},{false,3},{false,4},{false,5},{true,6},{false,7},{true,8
我有一个来自 .xls 电子表格的数据框,我打印了 print(df.columns.values) 列,输出包含一个名为:Poll Responses\n\t\t\t\t\t。 我查看了 Excel
This question already has answers here: What are good reasons for choosing invariance in an API like
指针类型作为类型前缀与在类型前加斜杠作为后缀有什么区别。斜线到底是什么意思? 最佳答案 语法 T/~ 和 T/& 基本上已被弃用(我什至不确定编译器是否仍然接受它)。在向新向量方案过渡的初始阶段,[T
我正在尝试找到一种方法来获取模板参数的基类。 考虑以下类: template class Foo { public: Foo(){}; ~Foo(){};
这是一个让我感到困惑的小问题。我不知道如何描述它,所以只看下面的代码: struct B { B() {} B(B&) { std::cout ::value #include
为什么有 T::T(T&) 而 T::T(const T&) 更适合 copy ? (大概是用来实现move语义的???) 原始描述(被melpomene证明是错误的): 在C++11中,支持了一种新
在 Java 7 中使用 eclipse 4.2 并尝试实现 List 接口(interface)的以下方法时,我收到了警告。 public T[] toArray(T[] a) { ret
假设有三个函数: def foo[T](a:T, b:T): T = a def test1 = foo(1, "2") def test2 = foo(List(), ListBuffer()) 虽
我对柯里化(Currying)和非柯里化(Currying)泛型函数之间类型检查的差异有点困惑: scala> def x[T](a: T, b: T) = (a == b) x: [T](a: T,
考虑一个类A,我如何编写一个具有与相同行为的模板 A& pretty(A& x) { /* make x pretty */ return x; } A pretty(A&& x) {
Eclipse 表示由于泛型类型橡皮擦,类型参数不允许使用 instanceof 操作。 我同意在运行时不会保留任何类型信息。但是请考虑以下类的通用声明: class SomeClass{ T
在 C++14 中: 对于任何整数或枚举类型 T 以及对于任何表达式 expr: 有没有区别: struct S { T t { expr }; }; 和 struct S { T t = { exp
我是一名优秀的程序员,十分优秀!