我有这个函数,它将fileData作为字节数组和文件路径.我得到的错误是它试图在代码bewlo中设置fileInfo.它说'物理路径给定,虚拟路径预期'
public override void WriteBinaryStorage(byte[] fileData, string filePath)
{
try
{
// Create directory if not exists.
System.IO.FileInfo fileInfo = new System.IO.FileInfo(System.Web.HttpContext.Current.Server.MapPath(filePath)); //when it gets to this line the error is caught
if (!fileInfo.Directory.Exists)
{
fileInfo.Directory.Create();
}
// Write the binary content.
System.IO.File.WriteAllBytes(System.Web.HttpContext.Current.Server.MapPath(filePath), fileData);
}
catch (Exception)
{
throw;
}
}
Run Code Online (Sandbox Code Playgroud)
在调试时,提供filePath为"E:\\WEBS\\webapp\\default\\images\\mains\\myimage.jpg".并且错误消息是
'E:/WEBS/webapp/default/images/mains/myimage.jpg' is a physical path, but a virtual path was expected.
Run Code Online (Sandbox Code Playgroud)
此外,触发此操作的是以下调用
properties.ResizeImage(imageName, Configurations.ConfigSettings.MaxImageSize, Server.MapPath(Configurations.EnvironmentConfig.LargeImagePath));
Run Code Online (Sandbox Code Playgroud) 我在main.xml中设置了一个ImageView,如果我想从我的View类访问它并使其可见= false,我该如何以编程方式执行此操作?
谢谢
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
theView = new GameView(this);
theView.setBackgroundResource(R.layout.main);
setContentView(theView);
Run Code Online (Sandbox Code Playgroud) 可能重复:
如何在C#中获取当前页面的URL
如果我在页面中说http://myweb/folder/obtain.aspx?thevalue=3,我怎样才能确定网址是否包含obtain.aspx?thevalue在c#中?我只需要检查用户是否登陆此特定页面.
PS:我想我真的不需要检查,?thevalue但只是obtain.aspx
我在我的PHP代码中有这个,它目前在同一个login.php页面中执行登录请求,但现在我想用Ajax来做.基本上我在login.php中有这个
echo '<form method="post" ><div id="login" class="login">
<label for="login">User Name</label>
<input type="text" name="logInUsername" />
<label for="Password">Password</label>
<input type="password" name="logInPassword" />
<input type="submit" value="Submit" name="submitlogin" class="button" />
</div>';
Run Code Online (Sandbox Code Playgroud)
我想仍然使用这个,但有一个login_request.php或其他我可以发送用户名和密码验证,然后改变<div id=login> to say you are logged in!</div>我可以用传统的方式,与表格发布..但现在我想尝试一下与Ajax.
任何帮助都感激不尽.
问候
我试图Page_LoadComplete在我的用户控件中使用myusercontrol.ascx.cs但它没有被激活,我添加了一个断点,什么也没有,用户控件可能不支持此事件?如果是这样的话,我可以使用什么呢?
如何获取设置为Visible = false的字段的值?如下:
<asp:BoundField DataField="ItemID" HeaderText="Line Item ID" Visible="false"/>
Run Code Online (Sandbox Code Playgroud)
但是,当我试图得到它
int temID = Convert.ToInt32(row.Cells[0].Text);
Run Code Online (Sandbox Code Playgroud)
它无法找到它并引发异常,但是如果我将它变为Visible ="true"则可行.
如果visible = false,我该如何检索值?
我有一个在aspx中默认设置为"false"的复选框.然后有一个函数来确定它是真还是假,问题是当在页面上有一个文本框,这个文本框上有一个TextChange事件,当我在文本框中键入内容然后转到复选框此时我可以看到第一次点击整页回发并重置复选框以取消选中..然后我需要再次点击它然后它会坚持..我该怎么做才能让它坚持第一次点击?
我可以使用一些javascript,或者你认为我的选择是什么?
protected void myTextbox_TextChanged(object sender, EventArgs e)
{
ShowCheckBox(true);
}
private void ShowCheckBox(bool ckVal)
{
myCheckBox.Visible = ckVal;
}
Run Code Online (Sandbox Code Playgroud) 您好我正在尝试重定向,如果响应是404,但它没有按预期工作,您可以专家看到问题吗?它仍然是通用的404
在我的Global.asax中
protected void Application_BeginRequest(Object sender, EventArgs e)
{
if (Response.Status == "404 Not Found")
{
string notFound = "~/custom_notfound.aspx";
Response.Redirect(notFound);
}
}
Run Code Online (Sandbox Code Playgroud)
UPDATE
到目前为止尝试过
(Response.Status == "404 Not Found")
(Response.Status == "404")
(Response.StatusCode == 404)
Run Code Online (Sandbox Code Playgroud) 我试图让如果该值是1或0基本上在我的数据库我称字段的复选框选中Active (bit, not null),我可以传递值到GridView ..但现在我要把它检查如果该位是1或不检查该位是否为0但它不起作用..它只显示未选中但该位为1.
<ItemTemplate>
<asp:CheckBox ID="ItemCheck" runat="server"
Enabled='<%# (DataBinder.Eval(Container.DataItem, "Active")) %>' />
</ItemTemplate>
Run Code Online (Sandbox Code Playgroud)
任何帮助将非常感激
我有一个用户控件,我有两个面板,一个在左边,另一个在右边,左边有一些客户账单信息,右边有一些发货信息,发货信息中的每个字段都有一个requiredfieldvalidator,这些面板包含在更新面板中.默认状态是两个面板都可见,在面板下方有一个复选框,上面写着"运费与结算相同",当您检查时,"运输面板"右侧的面板消失,然后继续.
问题:假设我删除了运输名称中的文本而我没有点击任何其他地方,然后我转到"与结算相同"复选框一会儿它以红色显示验证然后消失.我试过创建一个禁用验证器的函数,即
RequireFieldValidator1.Enabled = false;
Run Code Online (Sandbox Code Playgroud)
它在运输面板消失之前没有显示验证的条款下工作正常,但是我可以说我改变主意并再次点击它来显示它.现在,当我删除运输面板中的名称并单击其他位置时,它不会让我去任何地方,但它不会显示验证文本.
所以我做了这个逻辑:
if (ckSameBilling.checked)
{
RequiredFieldValidator.Enabled = false;
}
else
{
RequiredFieldValidator.Enabled = true;
}
Run Code Online (Sandbox Code Playgroud)
但现在它回到了我上面演示的相同行为,清除了运输名称并单击了checbox ..我可以暂时看到红色验证.
相关代码
//All this is wrapped in an update panel
<asp:Panel ID="pnl" runat="server"><div>
asp:TextBox ID="txtShippingFirstName" runat="server" Width="130px" Columns="30"
MaxLength="100" asp:TextBox><div>
<asp:RequiredFieldValidator ID="Requiredfieldvalidator1" ErrorMessage="Name Required"
ControlToValidate="txt"
runat="server" Display="Dynamic" CssClass="Error">
</asp:RequiredFieldValidator>
</asp:Panel>
<div style="margin-left: 145px;">
<asp:CheckBox ID="Billing" runat="server" Font-Bold="True"
Text"Same as Billing" OnCheckedChanged="Billing_CheckedChanged"
AutoPostBack="True" />
</div>
Run Code Online (Sandbox Code Playgroud)
代码隐藏:
protected void Billing_CheckedChanged(object sender, EventArgs e)
{
if (Billing.Checked)
{
//Disable the shipping …Run Code Online (Sandbox Code Playgroud)