小编Sar*_*aiz的帖子

提交表单前检查文件是否上传

我想在通过 JavaScript/jQuery 单击提交按钮之前检查用户是否上传了文件。

如果文件未上传,我不想允许表单提交。

我的html是:

<form action="/home/save" method="post" enctype="multipart/form-data" >   
    Upload Image: <input type="file" name="image" />  
    <input type="submit" value="upload" />
</form>
Run Code Online (Sandbox Code Playgroud)

javascript jquery

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

用户名可用性

我正在制作一个注册表格.它有一个名为的文本框UserName.我想点击按钮检查用户名可用性.我正在使用asp.net MVC4.点击按钮我调用了以下功能.如果用户名已在数据库中,则返回成功,但如果用户名不在数据库中,则不返回.它在执行查询时停止.这是我的功能代码.如果用户名不可用,我想返回false.

public JsonResult CheckUserName()
{
    string userName = Request["UserName"];

    var cx = new PostAdPage.Models.mydbEntities3();

    // Stops at this line if username is not available
    var u = cx.signups.First(x => x.username.Equals(userName));    

    if (u.username.Equals(userName))
    {
        return this.Json(true, JsonRequestBehavior.AllowGet);
    }
    else
    {
        return this.Json(false, JsonRequestBehavior.AllowGet);
    }
Run Code Online (Sandbox Code Playgroud)

c# entity-framework asp.net-mvc-4

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

在Canvas Android上旋转位图

我有一个扩展SurfaceView的类.我有一个针的图像,我通过Bitmap在画布上绘制.我想在点击按钮时用一个固定点旋转此针.旋转针的逻辑是什么?假设我在点击按钮时调用onDraw(Canvas画布),我想每次旋转5度针.这是我的代码

    public class PingPongSurfaceView extends SurfaceView implements SurfaceHolder.Callback
    {
      private Bitmap needle = null;

      public PingPongSurfaceView(Context context, AttributeSet attrs) {
            super(context, attrs);
            // TODO Auto-generated constructor stub
            setBackgroundResource(R.drawable.puzzle);

        needle = BitmapFactory.decodeResource(getResources(), R.drawable.sui);


        }

protected void onDraw(Canvas canvas) 
          {
        int needlex =0;
        int needley = 0;

            needlex = (mWidth/2) - needle.getWidth()+9;
    needley = (mHeight - (needle.getHeight()/2)-70);

            canvas.drawBitmap(needle, needlex, needley, null); //Bitmap to be rotate

          }

    }
Run Code Online (Sandbox Code Playgroud)

android canvas

0
推荐指数
1
解决办法
3036
查看次数