ActiveX control is not displaying.Need to know Why? - c#-3.0

Here I displayed the code.Suggest me,If anything wrong.
namespace MyActivex
{
public interface AxMyControl
{
String UserText { set; get; }
}
public partial class MyControl : UserControl,AxMyControl
{
string mystring;
public MyControl()
{
this.InitializeComponent();
this.Show();
//InitializeComponent();
}
public string UserText
{
get { return mystring; }
set
{
mystring = value;
textBox1.Text = value;
}
}
}
}
After building this code,created the dll and registered it successfully.And my html page is,
<html>
<body>
<form name="frm" id="frm">
<input type="text" name="txt" value="enter text here">
<input type="button" value="Click me" onClick="doScript();">
</form>
<object id="MyControl" name="MyControl" classid="MyActivex.dll#MyActivex.MyControl"
width=300 height=80>
</object>
</body>
<script language="javascript">
function doScript()
{
MyControl.UserText=frm.txt.value;
}
</script>
</html>
I have placed my html page in the same folder where the dll exists.While opening the html page it displays as follows.Help me to find what is going wrong.If this is a simple and stupid issue, forgive me.I searched a lot for the solution but i didn't find.So that only posting here.
IE Snapshot http://img136.imageshack.us/img136/4948/snapshotzl.jpg

I know this may sound snarky but this could be a pop-up blocker getting in the way, make sure that is turned off. It can cause issues like this

Related

How to add back the "loading" Element after removed it from Parent?

Ok, in war/MyProject.html, I have:
<body>
<div id="loading">
<div id="waitingForLoading"></div>
<BR/>
<img src="../images/loading.gif" />
</div>
...
</body>
in MyProject.java
public class OfflineMatching implements EntryPoint {
#Override
public void onModuleLoad() {
// this code works fine
if(DOM.getElementById("loading")!=null){
DOM.getElementById("loading").removeFromParent();
}
Button myButton=new Button("Enter Main Page");
RootPanel.get().add(myButton);
myButton.addClickHandler(new ClickHandler(){
#Override
public void onClick(ClickEvent event) {
// this code does not work
if(DOM.getElementById("loading")==null){
DOM.appendChild(RootPanel.getBodyElement(), DOM.createElement("loading"));
}
}
});
}
}
So, did i do anything wrong?
Why this code does not work?
// this code does not work
if(DOM.getElementById("loading")==null){
DOM.appendChild(RootPanel.getBodyElement(), DOM.createElement("loading"));
}
DOM.createElement(String tagName) creates a <tagname> element. So, if you pass "loading" to it, it will create a <loading> element.
For a quick workaround, you can use RootPanel.get, and then call setVisible on the widget:
// onModuleLoad:
RootPanel.get("loading").setVisible(false);
// onClick:
RootPanel.get("loading").setVisible(true);
But a better approach would be creating the loading <div> as a widget in GWT and just call setVisible on its instance, without relying on ids.

MVC4 custom remote validator message appears, but is ignored at form submit

I have an MVC4 registration form that employs two custom remote validators. The first validator checks for email uniqueness, and works properly. The second checks number of uses for a voucher code. It correctly displays a message after entering a voucher code, but it fails to honor the custom remote validation at the point of submission.
In other words, you can enter a voucher code and see the "Cannot use voucher..." message from the remote validator. But you can still submit the form.
This is the abbreviated markup for the form, with just the relevant fields and the submit button. The full form is much larger. The email fields, which use custom validation successfully, are retained in this example for comparison. You can see the RegistrationVoucherCode field and validator near the end of the form.
#using (Html.BeginForm("Index", "Registration", FormMethod.Post))
{
<div class="row">
<div class="col-lg-6 col-md-6 col-xs-6 field_wrapper">
<div class="form_label">#Html.LabelFor(m => m.EmailAddress)</div>
<div class="form_field">#Html.TextBoxFor(m => m.EmailAddress)</div>
<div class="form_validator">#Html.ValidationMessageFor(m => m.EmailAddress)</div>
</div>
<div class="col-lg-6 col-md-6 col-xs-6 field_wrapper">
<div class="form_label">Confirm Email</div>
<div class="form_field">#Html.TextBoxFor(m => m.ConfirmEmail)</div>
<div class="form_validator">#Html.ValidationMessageFor(m => m.ConfirmEmail)</div>
</div>
</div>
<div class="row">
<div class="col-lg-6 col-md-6 col-xs-6 field_wrapper">
<div class="form_label">#Html.LabelFor(m => m.RegistrationVoucherCode)</div>
#{
string displayVoucherCode = Model.RegistrationVoucherCode.ToString();
if (Model.RegistrationVoucherCode == 0)
{
displayVoucherCode = string.Empty;
}
}
<div class="form_field">#Html.TextBoxFor(m => m.RegistrationVoucherCode, new { Value = displayVoucherCode, maxlength = 7 })</div>
<div class="form_validator">#Html.ValidationMessageFor(m => m.RegistrationVoucherCode)</div>
</div>
<div class="col-lg-6 col-md-6 col-xs-6 field_wrapper">
</div>
</div>
<div class="row">
<div class="col-xs-12">
<input type="submit" id="submitForm" value="Next" class="standard_button right_button" />
</div>
</div>
}
This is related code from my ProfileModel. The full model is much larger, so only relevant code is presented here. At the end of this you can see RegistrationVoucherCode.
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
namespace SW.CEA.WebSite.Models.Registration
{
public class ProfileModel
{
public ProfileModel()
{
}
public Profile Profile { get; set; }
[Required(ErrorMessage = "Confirm Email is required.")]
[Display(Name = "Confirm Email")]
[StringLength(128)]
[RegularExpression(#"\w+([-+.']\w+)*#\w+([-.]\w+)*\.\w+([-.]\w+)*", ErrorMessage = "Confirm Email Address is Not Valid")]
[System.Web.Mvc.Compare("EmailAddress", ErrorMessage = "Email addresses do not match..")]
public string ConfirmEmail
{
get
{
return Profile.ConfirmEmail;
}
set
{
Profile.ConfirmEmail = value;
}
}
[Required(ErrorMessage = "Email Address is required.")]
[Display(Name = "Email")]
[StringLength(128)]
[Remote("ValidateEmailUniqueness", "Registration")]
[RegularExpression(#"\w+([-+.']\w+)*#\w+([-.]\w+)*\.\w+([-.]\w+)*", ErrorMessage = "Email Address is Not Valid")]
public string EmailAddress
{
get
{
return Profile.EmailAddress;
}
set
{
Profile.EmailAddress = value;
}
}
[Required(ErrorMessage = "Order Code is required.")]
[Display(Name = "Order Code")]
[Remote("ValidateVoucherCode", "Registration")]
public int RegistrationVoucherCode
{
get
{
return Profile.RegistrationVoucherCode;
}
set
{
Profile.RegistrationVoucherCode = value;
}
}
}
}
And these are custom validators from my RegistrationController. Again, email address validators appear here for comparison. My problem is with enforcing the ValidateVoucherCode custom validator at the point of form submission.
private bool IsEmailUnique(string EmailAddress)
{
var profile = ProfileRepository.GetProfile(EmailAddress);
return (profile == null);
}
[HttpGet]
public JsonResult ValidateEmailUniqueness(string EmailAddress)
{
if (!IsEmailUnique(EmailAddress))
{
return Json("Error, email address is already registered, please sign in.", JsonRequestBehavior.AllowGet);
}
return Json(true, JsonRequestBehavior.AllowGet);
}
[HttpGet]
public JsonResult ValidateVoucherCode(int RegistrationVoucherCode)
{
var voucher = VoucherRepository.GetVoucherWithProfiles(RegistrationVoucherCode);
if (voucher == null)
{
return Json("Invalid Order Code", JsonRequestBehavior.AllowGet);
}
if (voucher.Profiles.Count >= Settings.Default.MaxVoucherUses)
{
return Json("Cannot user voucher, will exceed maximum number of voucher uses.", JsonRequestBehavior.AllowGet);
}
return Json(true, JsonRequestBehavior.AllowGet);
}
The message, "Cannot user voucher, will exceed maximum number of voucher uses," will successfully appear on the client in this ValidationMessageFor when an overused validation code is entered. This again is from the form.
#Html.TextBoxFor(m => m.RegistrationVoucherCode, new { Value = displayVoucherCode, maxlength = 7 })
#Html.ValidationMessageFor(m => m.RegistrationVoucherCode)
Upon tabbing off the form field, debugger shows this remote validator being hit.
[HttpGet]
public JsonResult ValidateVoucherCode(int RegistrationVoucherCode)
So the ValidateVoucherCode custom validator is doing part of it's job. It's showing the "Cannot use voucher..." message when I tab off the field. But it doesn't prevent the form from being submitted. By contrast, the unique email address validator on the same form will prevent form submission. I need the RegistrationVoucherCode validator to operate in the same manner. Thanks for your help.
The solution was to replace jquery-2.1.0.min.js with https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js.
The scripts that my form presently uses are:
https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js
jquery.validate.min.js
jquery.validate.unobtrusive.min.js

Wicket submit action doesn't work

After updating Wicket from version 6.12 to 6.13/6.14 onSubmit action doesn't work. For Example class:
public class LoginPage extends WebPage {
private String username = "";
private String password = "";
public LoginPage() {
super();
Form<?> form = new Form<Void>("form");
setDefaultModel(new CompoundPropertyModel<>(this));
form.add(new Button("submit") {
#Override
public void onSubmit() {
System.out.println("SUBMIT "+username+":"+password);
}
});
form.add(new TextField<String>("username").setRequired(true));
form.add(new PasswordTextField("password").setRequired(true));
add(form);
}
}
with HTML:
<!DOCTYPE html>
<html xmlns:wicket>
<body>
<form wicket:id="form">
<input id="name" type="text" placeholder="Username" wicket:id="username">
<input id="password" type="password" placeholder="Password" wicket:id="password">
<input type="submit" wicket:id="submit" value="Enter">
</form>
</body>
</html>
doesn't works with wicket version 6.13+ and great work with wicket 6.12-. Changing Button on something like SubmitLink doesn't help.
Could you tell me what's wrong?
Well... hacky but it seems to work with 6.15.
Replace encodePageComponentInfo with the following one.
#Override
protected void encodePageComponentInfo(Url url, PageComponentInfo info) {
Args.notNull(url, "url");
if (info != null) {
String s = info.toString();
if (!Strings.isEmpty(s)) {
try {
Integer.parseInt(s);
} catch (Exception e) {
QueryParameter parameter = new QueryParameter(s, "");
url.getQueryParameters().add(parameter);
}
}
}
}
I found problem in my test project. I use changed MountedMapper for hiding version number in the URL:
/**
* Wrapper for hiding the version number in the URL
*/
public class SimpleMountedMapper extends MountedMapper {
public SimpleMountedMapper(String mountPath, Class<? extends IRequestablePage> pageClass) {
super(mountPath, pageClass, new PageParametersEncoder());
}
#Override
protected void encodePageComponentInfo(Url url, PageComponentInfo info) {
}
public Url mapHandler(IRequestHandler requestHandler) {
if (requestHandler instanceof ListenerInterfaceRequestHandler) {
return null;
} else {
return super.mapHandler(requestHandler);
}
}
}
In new version of wicket something wrong with this implementation (got it from this question).

Reusing wicket component in a form

I have built a wicket component that contains input/labels and methods to change presentation (required, enabled, etc.). The components render fine, but what happens is when the form submits I see only 1 form parameter 'input', and it's the last InputRow component.
InputRow.html
<html xmlns:wicket="http://wicket.apache.org">
<head>
<link rel="stylesheet" type="text/css" href="style.css"/>
</head>
<body>
<wicket:panel>
<label wicket:id="label">abc: <span class="req">*</span></label>
<span class="input">
<input wicket:id="input" type="text" id="name"></input>
</span>
<span wicket:id="input_feedback"></span>
</wicket:panel>
</body>
</html>
InputRow.java
package com.wicket;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.feedback.FeedbackMessage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.Model;
public class InputRow extends Panel{
#SuppressWarnings("unused")
private String id;
public InputRow(String id, String label) {
super(id);
this.id = id;
Label memberIdLabel = new Label("label",label);
memberIdLabel.setEscapeModelStrings(false)
.add(new AttributeAppender("for", new Model<String>(id),""));
add(memberIdLabel);
TextField<String> name = new TextField<String>("input");
name.setType(String.class)
.setMarkupId(id)
.setOutputMarkupId(true);
add(name);
add(new Label("input_feedback",""));
}
public InputRow disable()
{
get("input")
.setEnabled(false)
.add(new AttributeAppender("class", new Model<String>("disabled"),""));
get("label")
.add(new AttributeAppender("class", new Model<String>("disabled"),""));
return this;
}
public InputRow required()
{
Model model = (Model)get("label").getInnermostModel();
StringBuffer label = new StringBuffer((String)model.getObject());
label.append(" <span class=\"req\">*</span>");
model.setObject(label);
((TextField)get("input")).setRequired(true);
return this;
}
#Override
protected void onBeforeRender() {
super.onBeforeRender();
Label feedback = (Label)get("input_feedback");
if (get("input").getFeedbackMessage() != null)
{
feedback.setDefaultModel(new Model<String>("Required"));
}
}
}
Adding to the form component
add(new InputRow("name","Name:").required());
edit
I didn't set up a ListView or repeater since I know what rows / fields I want to add to the form at build time.
Your InputFields are missing their models. This way, wicket doesn't know where to store the formdata. If you add models to the fields they will be populated automatically.
There's not just one form parameter submitted. The submits are of the named like name:input, name2:input, ...
But as Nicktar suggests in the comment you should use a model to bind the value of the form component to your entity object. You have to accept an IModel in the constructor and use it in the constructor of TextField.
A better approach to what you are trying to do is to write a Behavior which adds decorating markup for your FormComponent. That way it works for more than just simple text input fields and you can fully customize the instances of your FormComponents.
It could look like this:
public class FormComponentBehavior extends Behavior {
#Override
public void bind(Component component) {
if (!(component instanceof FormComponent)) {
throw new IllegalArgumentException();
}
}
#Override
public void beforeRender(Component component) {
FormComponent<?> fc = (FormComponent<?>) component;
Response r = component.getResponse();
r.write("<label" + (fc.isRequired() ? " class='required'" : "") + ">");
r.write(fc.getLabel().getObject());
r.write("</label>");
r.write("<span class='input'>");
}
#Override
public void afterRender(Component component) {
component.getResponse().write("</span>");
// if feedback errors write them to markup...
}
}
Then you have to add this behavior to your FormComponent instances.
Maybe the problem with your form is that your input text fields have all the same id. Try using attribute 'name' instead of 'id'

SQL Server Reporting Services: Report Viewer works locally, not on server

We are having a problem with SSRS and the Report Viewer. We are using a simple aspx page to show our reports:
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="ReportView.aspx.cs" Inherits="Estam.Web.ReportView" %>
<%# Register Assembly="Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body style="margin: 0">
<form id="form1" runat="server">
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt"
ProcessingMode="Remote" Width="100%" SizeToReportContent="true" ZoomPercent="100"
ShowCredentialPrompts="False" ShowParameterPrompts="False" AsyncRendering="False">
<ServerReport />
</rsweb:ReportViewer>
</form>
</body>
</html>
using System;
using System.Configuration;
using System.Linq;
using System.Net;
using System.Security.Principal;
using System.Web.UI;
using Microsoft.Reporting.WebForms;
namespace Estam.Web
{
public partial class ReportView : Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(IsPostBack) return;
ReportViewer1.ServerReport.ReportServerCredentials = new EstamReportServerCredentials();
ReportViewer1.ServerReport.ReportServerUrl = new Uri(ConfigurationManager.AppSettings["ReportServerUrl"]);
ReportViewer1.ServerReport.ReportPath = "/tierviewnet/Reports/" + Request.QueryString["report_name"];
ReportViewer1.ShowParameterPrompts = true;
ReportViewer1.ServerReport.SetParameters(
Request.QueryString.AllKeys
.Where(key => key != "report_name")
.Select(key => new ReportParameter(key, Request.QueryString[key]) {Visible = false})
);
}
private class EstamReportServerCredentials : IReportServerCredentials
{
public bool GetFormsCredentials(out Cookie authCookie, out string userName, out string password, out string authority)
{
authCookie = null;
userName = null;
password = null;
authority = null;
return false;
}
public WindowsIdentity ImpersonationUser
{
get { return null; }
}
public ICredentials NetworkCredentials
{
get
{
return new NetworkCredential(
ConfigurationManager.AppSettings["ReportServerUser"],
ConfigurationManager.AppSettings["ReportServerPassword"],
ConfigurationManager.AppSettings["ReportServerDomain"]);
}
}
}
}
}
We're not doing anything crazy here, simply showing a report. When we run the application locally in the debugger it works fine. When the application is deployed to IIS, the reports are displayed, but the toolbar doesn't show images and none of the export functionality works.
Any help with this would be GREATLY appreciated.
It is probably due to a difference between Visual Studio development web server and IIS, specifically the way IIS handles web.config.
Please check this post for the complete solution.